/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package function;

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;
import mainpackage.Constant;
import mainpackage.InputInterFace;
import mainpackage.MainLogic;
import mainpackage.MainCanvas;
import mainpackage.MainView;
import mainpackage.Tools;
import mainpackage.ResManager;
import mainpackage.GameBean;
import engine.goods.Goods;
import java.util.Vector;
import mainpackage.MainGame;
import ui.UiInterFace;

/**
 *
 * NPC 对话和任务界面
 * @author lenovo
 */
public class NPCTalk {

    private Image[] imgArray;
    private String[] sArray;
    private int[] iArray;
    public int iPositionY = 0;
    private boolean bUiKeyPressLock = false;
    public String sTalkContent; //npc对话的内容
    public byte[] byTaskState;
    public long lNPCID = 0L;  //npc的唯一ID
    private int iWidth = 0;
    private int iHeight = 0;
    private int iStartX = 0;
    private int iStartY = 0;
    public byte byPopUpState = -1; //记录界面弹出层的UI状态变化
    public byte byState = 0; //记录在跟新页面状态的时候的小状态
    public byte byContentPageSelectIndex = 1; //内容的选中索引
    public byte byPageIndex = 1;////功能内容的选中索引
    public byte bySelectIndex = 1;  //总的选中索引
    public byte byMaxContentPage = -1;//内容最大页数-1,0,表示没有内容
    public byte byTotalNum = -1;//npc身上的功能和任务最大总数-1,0,表示没任务或是功能
    public byte byMaxPage = -1;
    public byte byMaxSelectIndex = -1;
    public String sNpcName; //npc名称
    private short shTextHeight = 0;
    private String sTaskName = null; //任务名称
    private String sTaskDesc = null;  //任务描述
    private String sTaskTarget = null; //任务目标 
    public String[] sItems = null;
    public byte byTaskItemChoiceStyle = -1;  //任务奖励道具方式(0,全给, 1，玩家选择一个)
    private byte byTaskUiState = 0; //界面状态,1,显示接受任务界面，2，任务查询界面,3，完成的任务界面
    public String sTaskKey = null; //任务的key
    public Goods items;
    public long lMoney; //任务奖励的金钱
    private int iTaskAwardExp;//任务奖励的金钱
    private int iTaskAwardPower;//任务奖励的修为
    public byte byRepairType; //修理类型
    public String[] sNPCTaskFuncArray; //npc身上的任务和功能数组
    private int infoHeight;//提示信息高度  
    private String[] info;//提示信息内容
    public boolean bShowMenu = false; //显示弹出菜单
    public String[] sOpArray;
    public byte bySubSelectIndex;
    public int iSubPositionY = 0;
    //任务相关坐标
    private int[] iTaskCoordinate; //(0-1,接受任务坐标.2-3,完成任务坐标,4-4:归还任务坐标)
    //任务场景可以
    private String[] sSenceKey; //任务场景的key,(0,接受任务场景可以,1,完成任务场景key,2,归还任务可以);
    private short shSendstoneNum = 0;//背包中传送石头数量
    public byte byUiState = 0;
    private boolean bFlag = false;
    public byte bySingleTaskState = -1;//(0,未接,1,已接没有完成，2，已经完成，3，失败//单个任务)（任务列表中便是可接主线任务的状态:-1：不是主线任务,0:是主线任务但是不能接；1：是主线任务而且可以接）
    public byte byTabIndex = 0;
    public byte byItemSelectIndex;
    private byte byMenuIndex = 0;
    private short shHeight;
    private short shTaskLevel;
    private byte byItemJobLimit = 0;
    private byte byShowAcceptArrow = -1;
    //记录上次接受任务的key和任务类型
    public static byte byPreTaskType = -1; //* 0,  狩猎 1, 收集 2,  对话 3  邮寄 4,  探索 5,  摧毁
    public static String sPreTaskKey = null;
    private byte byCurrentTaskType = 0;
    public static boolean bDelPreTaskKey = false;
    public static byte byNumPerPage;
    public int iStartPointY = 0;

    /**
    0 ---- 未接
    1 ---- 未完成
    2 ---- 失败
    3 ---- 完成
    4 ---- 已领取过奖了
    5 ---- 未知
    
     */
    /****************************分隔线**********NPC对话************************************************************************************************/
    public void setNPCTalk(long lNPCID, String sTalkContent, String[] sNPCFuncArray, String[] sNPCTaskArray, byte[] byTaskState) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        this.lNPCID = lNPCID;
        this.sNPCTaskFuncArray = null;
        //0:类型（1，任务，2，功能）;1：功能和任务ID;2:功能和任务名称;3:任务的状态
        if (sNPCFuncArray != null && sNPCFuncArray.length > 0) {
            byte byStorePos = -1;
            byte byRepairPos = -1;
            String[] sTempArray = null;
            //出售物品
            for (byte i = 0; i < sNPCFuncArray.length; i += 2) {
                if (sNPCFuncArray[i].equals("store")) {
                    byStorePos = i;
                    break;
                }
            }
            if (byStorePos > -1) {
                sTempArray = new String[sNPCFuncArray.length + 2];
                for (int i = 0; i < sNPCFuncArray.length; i += 2) {
                    if (i < byStorePos) {
                        sTempArray[i] = sNPCFuncArray[i];
                        sTempArray[i + 1] = sNPCFuncArray[i + 1];
                    } else if (i == byStorePos) {
                        sTempArray[i] = "buyItems";
                        sTempArray[i + 1] = "购买道具";
                        sTempArray[i + 2] = "soldItems";
                        sTempArray[i + 3] = "出售道具";
                    } else if (i > byStorePos) {
                        sTempArray[i + 2] = sNPCFuncArray[i];
                        sTempArray[i + 3] = sNPCFuncArray[i + 1];
                    }
                }
                sNPCFuncArray = sTempArray;
            }
            //牌子兑换
            byStorePos = -1;
            for (byte i = 0; i < sNPCFuncArray.length; i += 2) {
                if (sNPCFuncArray[i].equals("taozhuang")) {
                    byStorePos = i;
                    break;
                }
            }
            if (byStorePos > -1) {
                sTempArray = new String[sNPCFuncArray.length + 2];
                for (int i = 0; i < sNPCFuncArray.length; i += 2) {
                    if (i < byStorePos) {
                        sTempArray[i] = sNPCFuncArray[i];
                        sTempArray[i + 1] = sNPCFuncArray[i + 1];
                    } else if (i == byStorePos) {
                        sTempArray[i] = sNPCFuncArray[i];
                        sTempArray[i + 1] = sNPCFuncArray[i + 1];
                        sTempArray[i + 2] = "soldItems";
                        sTempArray[i + 3] = "出售道具";
                    } else if (i > byStorePos) {
                        sTempArray[i + 2] = sNPCFuncArray[i];
                        sTempArray[i + 3] = sNPCFuncArray[i + 1];
                    }
                }
                sNPCFuncArray = sTempArray;
            }
            //徽记兑换
            byStorePos = -1;
            for (byte i = 0; i < sNPCFuncArray.length; i += 2) {
                if (sNPCFuncArray[i].equals("bangpaihuiji")) {
                    byStorePos = i;
                    break;
                }
            }
            if (byStorePos > -1) {
                sTempArray = new String[sNPCFuncArray.length + 2];
                for (int i = 0; i < sNPCFuncArray.length; i += 2) {
                    if (i < byStorePos) {
                        sTempArray[i] = sNPCFuncArray[i];
                        sTempArray[i + 1] = sNPCFuncArray[i + 1];
                    } else if (i == byStorePos) {
                        sTempArray[i] = sNPCFuncArray[i];
                        sTempArray[i + 1] = sNPCFuncArray[i + 1];
                        sTempArray[i + 2] = "soldItems";
                        sTempArray[i + 3] = "出售道具";
                    } else if (i > byStorePos) {
                        sTempArray[i + 2] = sNPCFuncArray[i];
                        sTempArray[i + 3] = sNPCFuncArray[i + 1];
                    }
                }
                sNPCFuncArray = sTempArray;
            }

            //收邮件和发件箱
            byStorePos = -1;
            for (byte i = 0; i < sNPCFuncArray.length; i += 2) {
                if (sNPCFuncArray[i].equals("mail")) {
                    byStorePos = i;
                    break;
                }
            }
            if (byStorePos > -1) {
                sTempArray = new String[sNPCFuncArray.length + 2];
                for (int i = 0; i < sNPCFuncArray.length; i += 2) {
                    if (i < byStorePos) {
                        sTempArray[i] = sNPCFuncArray[i];
                        sTempArray[i + 1] = sNPCFuncArray[i + 1];
                    } else if (i == byStorePos) {
                        sTempArray[i] = "reciveMailBox";
                        sTempArray[i + 1] = "收件箱";
                        sTempArray[i + 2] = "sendMailBox";
                        sTempArray[i + 3] = "发件箱";
                    } else if (i > byStorePos) {
                        sTempArray[i + 2] = sNPCFuncArray[i];
                        sTempArray[i + 3] = sNPCFuncArray[i + 1];
                    }
                }
                sNPCFuncArray = sTempArray;
            }

            //修理装备
            byRepairPos = -1;
            for (byte i = 0; i < sNPCFuncArray.length; i += 2) {
                if (sNPCFuncArray[i].equals("repair")) {
                    byRepairPos = i;
                    break;
                }
            }
            //repairSystemicEquipment  修理全身装备 repairPackageEquipment 修理背包装备 soldWhiteEquipment 出售所有白装
            if (byRepairPos > -1) {
                sTempArray = new String[sNPCFuncArray.length + 4];
                for (byte i = 0; i < sNPCFuncArray.length; i += 2) {
                    if (i < byRepairPos) {
                        sTempArray[i] = sNPCFuncArray[i];
                        sTempArray[i + 1] = sNPCFuncArray[i + 1];
                    } else if (i == byRepairPos) {
                        sTempArray[i] = "repairSystemicEquipment";
                        sTempArray[i + 1] = "修理全身装备";
                        sTempArray[i + 2] = "repairPackageEquipment";
                        sTempArray[i + 3] = "修理背包装备";
                        sTempArray[i + 4] = "soldWhiteEquipment";
                        sTempArray[i + 5] = "出售所有白装";
                    } else if (i > byRepairPos) {
                        sTempArray[i + 4] = sNPCFuncArray[i];
                        sTempArray[i + 5] = sNPCFuncArray[i + 1];
                    }
                }
                sNPCFuncArray = sTempArray;
                sTempArray = null;
            }
        }

        this.byTotalNum = 0;
        byte byTaskLength = 0;
        if (sNPCTaskArray != null) {
            byTaskLength = (byte) (sNPCTaskArray.length / 2);
            this.byTotalNum += byTaskLength;
            byte tempByte;
            String tempTaskKey;
            String tempTaskName;
            for (int i = 0; i < byTaskLength; i++) {
                for (int j = i; j < byTaskLength; j++) {
                    if (byTaskState[i] != 0 && byTaskState[j] == 0) {//将“未接任务”靠前
                        tempByte = byTaskState[i];
                        byTaskState[i] = byTaskState[j];
                        byTaskState[j] = tempByte;

                        tempTaskKey = sNPCTaskArray[2 * i];
                        sNPCTaskArray[2 * i] = sNPCTaskArray[2 * j];
                        sNPCTaskArray[2 * j] = tempTaskKey;

                        tempTaskName = sNPCTaskArray[2 * i + 1];
                        sNPCTaskArray[2 * i + 1] = sNPCTaskArray[2 * j + 1];
                        sNPCTaskArray[2 * j + 1] = tempTaskName;
                    }

                    if (byTaskState[i] != 3 && byTaskState[j] == 3) {//再将“已完成任务”靠前
                        tempByte = byTaskState[i];
                        byTaskState[i] = byTaskState[j];
                        byTaskState[j] = tempByte;

                        tempTaskKey = sNPCTaskArray[2 * i];
                        sNPCTaskArray[2 * i] = sNPCTaskArray[2 * j];
                        sNPCTaskArray[2 * j] = tempTaskKey;

                        tempTaskName = sNPCTaskArray[2 * i + 1];
                        sNPCTaskArray[2 * i + 1] = sNPCTaskArray[2 * j + 1];
                        sNPCTaskArray[2 * j + 1] = tempTaskName;
                    }
                }
            }
            tempTaskKey = null;
            tempTaskName = null;
        }
        if (sNPCFuncArray != null) {
            this.byTotalNum += sNPCFuncArray.length / 2;
        }
        if (this.byTotalNum > 0) {
            this.sNPCTaskFuncArray = new String[this.byTotalNum * 4];
            if (byTaskLength > 0) {
                for (byte i = 0; i < byTaskLength; i++) {
                    this.sNPCTaskFuncArray[4 * i] = "t";
                    this.sNPCTaskFuncArray[4 * i + 1] = sNPCTaskArray[2 * i];
                    this.sNPCTaskFuncArray[4 * i + 2] = this.getTaskNamePre(sNPCTaskArray[2 * i], (byte) 2) + sNPCTaskArray[2 * i + 1];
                    this.sNPCTaskFuncArray[4 * i + 3] = String.valueOf(byTaskState[i]);
                }
            }
            if (sNPCFuncArray != null) {
                for (byte i = 0; i < this.byTotalNum - byTaskLength; i++) {
                    this.sNPCTaskFuncArray[byTaskLength * 4 + 4 * i] = "f";
                    this.sNPCTaskFuncArray[byTaskLength * 4 + 4 * i + 1] = sNPCFuncArray[2 * i];
                    this.sNPCTaskFuncArray[byTaskLength * 4 + 4 * i + 2] = sNPCFuncArray[2 * i + 1];
                    this.sNPCTaskFuncArray[byTaskLength * 4 + 4 * i + 3] = "";
                }
            }
        }
        this.sTalkContent = sTalkContent;
        if (sNpcName != null && sNpcName.equals("帮派大管家")) {//帮派大堂NPC
            info = new String[]{"可进行特殊建筑物的建造。已建造的建筑可在这里面进行升级。", "帮主、副帮主和护法职位可在此修改帮派公告。",
                "在此查看所在家园帮派的信息", "在此传出帮派家园"};
            Tools.rollIndex = 0;
            infoHeight = Tools.getParagraphHeight(info[0], 209, 38);
        }
        this.bySelectIndex = 1;

        this.shTextHeight = 0;
        //#if NOKIA_S60V5
         this.iWidth = 310;
         this.iHeight = 35;
         if (sTalkContent != null && sTalkContent.length() > 1) {
             this.shTextHeight = (short) (Tools.getParagraphHeight(sTalkContent, 290, Constant.FONT_SMALL_HEIGHT) + 10);
             this.iHeight += this.shTextHeight;
         }
        //#else
//#        this.iWidth = 232;
//#        this.iHeight = 26;
//#        if (sTalkContent != null && !"".equals(sTalkContent)) {
//#            this.shTextHeight = (short) (Tools.getParagraphHeight(sTalkContent, 212, Constant.FONT_SMALL_HEIGHT) + 10);
//#            this.iHeight += this.shTextHeight;
//#        }
        //#endif
        this.byTotalNum = 0;
        if (this.sNPCTaskFuncArray != null) {
            this.byTotalNum = (byte) (this.sNPCTaskFuncArray.length / 4);
        }
        if (this.byTotalNum > 0) {
            if (this.byTotalNum <= 4) {
                this.iHeight += this.byTotalNum * (Constant.FONT_SMALL_HEIGHT + 4) + 10; //功能
                this.byMaxPage = 1;
                this.byPageIndex = 1;
            } else {
                this.iHeight += (Constant.FONT_SMALL_HEIGHT + 4) * 4 + 22; //功能
                this.byMaxPage = (byte) Tools.ceil(this.byTotalNum, 4);
                this.byPageIndex = 1;
            }
        } else {
            this.byMaxPage = 0;
            this.byPageIndex = 1;
        }
        //#if NOKIA_S60V5
         if (this.iHeight < 120) {
             this.iHeight = 120;
         }
         if (this.byTotalNum > 0) {
             this.iPositionY = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 35 + Constant.FONT_SMALL_HEIGHT + this.shTextHeight;
         }
        //#else
//#        if (this.iHeight < 90) {
//#            this.iHeight = 90;
//#        }
//#        if (this.byTotalNum > 0) {
//#            this.iPositionY = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 26 + Constant.FONT_SMALL_HEIGHT + this.shTextHeight;
//#        }
        //#endif
//        MainLogic.getInstance().pushState(Constant.GAME_UI_NPC_TALK, true);
        this.byUiState = 0;
        this.byState = 0;
        this.bUiKeyPressLock = false;
    }

    public void openNPCTalk(String sNpcName) {
//        if (GameBean.BY_SCENE == 2) {
//            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "只有本帮成员才可以进行操作。");
//            MainLogic.getInstance().bSendLockedNpcInfo = false;
//            return;
//        }
        this.sNpcName = sNpcName;
        if (this.sNpcName == null) {
            this.sNpcName = "";
        }
        MainLogic.getInstance().pushState(Constant.GAME_UI_NPC_TALK, false);
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_NPC, Constant.SOCKET_MSG_TYPE_LOGIC);

    }

    /**
     * 初始化npc对话资源
     */
    public void initNPCTalk() {
    	MainCanvas.clearUI(Constant.GAME_UI_NPC_TALK);
        try {
            //弹出层的图片数组
            //#if NOKIA_S60V5
             this.imgArray = new Image[10];
             this.imgArray[0] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
             this.imgArray[1] = ResManager.createImage(90000044);    //白色文字
             this.imgArray[2] = ResManager.createImage(90000041);            //箭头
             this.imgArray[3] = Tools.makeBlueMask(); //蓝色光图
             this.imgArray[4] = Tools.makeTransparent(ResManager.createImage(90000004), 240);            //任务问号
             this.imgArray[5] = ResManager.createImage(90000047);            //大数字
             this.imgArray[6] = ResManager.createImage(90000043);            //确定文字
             this.imgArray[9] = ResManager.createImage(90000086);//蓝条
             this.imgArray[8] = ResManager.createImage(90000090);//方向
             this.imgArray[7] = ResManager.createImage(90000094);            //等待中图片
            //#else
//#            this.imgArray = new Image[8];
//#            this.imgArray[0] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
//#            this.imgArray[1] = ResManager.createImage(90000044);    //白色文字
//#            this.imgArray[2] = ResManager.createImage(90000041);            //箭头
//#            this.imgArray[3] = Tools.makeBlueMask(); //蓝色光图
//#            this.imgArray[4] = Tools.makeTransparent(ResManager.createImage(90000004), 240);            //任务问号
//#            this.imgArray[5] = ResManager.createImage(90000047);            //大数字
//#            this.imgArray[6] = ResManager.createImage(90000043);            //确定文字
//#            this.imgArray[7] = ResManager.createImage(90000094);            //等待中图片
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
//            System.out.print("弹出层图片载入异常");
        }
        this.sArray = new String[]{"shuoming", "帮派大管家", "t", "f"};
        this.bUiKeyPressLock = true;
        this.bySelectIndex = 1;
        this.shTextHeight = 0;
        //#if NOKIA_S60V5
         this.iWidth = 310;
         this.iHeight = 120;
        //#else
//#        this.iWidth = 232;
//#        this.iHeight = 80;
        //#endif
        this.byPopUpState = 1;
        this.sTalkContent = null;
        this.sNPCTaskFuncArray = null;
        this.byTotalNum = 0;
        this.shTextHeight = 0;
        this.byUiState = 2;
        this.byState = 1;
        rollindex = 0;
    }

    /**
     * 更新npc对话逻辑
     */
    public void updateNPCTalk() {
        if (this.byPopUpState < 4) {
            this.byPopUpState++;
            MainCanvas.clearInput();
            return;
        }
        switch (this.byUiState) {
            case 0:
                if (!GameBean.b_WAIT_NET_MSG_BACK) {
                    if (!bUiKeyPressLock) {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                            if (this.bySelectIndex > 1) {
                                this.byState = 2;
                                if (this.bySelectIndex == 5) {
                                    if (this.byPageIndex * 4 > this.byTotalNum) {
                                        this.bySelectIndex = (byte) (this.byTotalNum - (this.byPageIndex - 1) * 4);
                                    } else {
                                        this.bySelectIndex = (byte) (this.bySelectIndex - 1);
                                    }
                                } else {
                                    this.bySelectIndex = (byte) (this.bySelectIndex - 1);
                                }
                                this.bUiKeyPressLock = true;
                                //#if NOKIA_S60V5
                                 this.iArray = new int[]{2, 1, Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 35 + this.shTextHeight, 2, 150, 5};
                                //#else
//#                                this.iArray = new int[]{2, 1, Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 26 + this.shTextHeight, 2, 150, 5};
                                //#endif
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                    case 3:
                                    case 4:
                                        this.iArray[2] += this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 4) - 2;
                                        break;
                                }
                            }
                            if (sNpcName.equals(this.sArray[1])) {
                                Tools.rollIndex = 0;
                                infoHeight = Tools.getParagraphHeight(info[bySelectIndex - 1], 209, 38);
                                rollindex = 0;
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                            if (this.byMaxPage > 0 && this.bySelectIndex < 5) {
                                if ((this.byPageIndex - 1) * 4 + this.bySelectIndex == this.byTotalNum) {
                                    if (this.byPageIndex == this.byMaxPage && this.byMaxPage <= 1) {
                                        MainCanvas.clearInput();
                                        return;
                                    }
                                    this.bySelectIndex = 5;
                                } else {
                                    this.bySelectIndex = (byte) (this.bySelectIndex + 1);
                                }
                                this.byState = 1;
                                this.bUiKeyPressLock = true;
                                //#if NOKIA_S60V5
                                 this.iArray = new int[]{1, 1, Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 35 + this.shTextHeight, 2, 150, 5};
                                //#else
//#                                this.iArray = new int[]{1, 1, Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 26 + this.shTextHeight, 2, 150, 5};
                                //#endif
                                switch (this.bySelectIndex) {
                                    case 2:
                                    case 3:
                                    case 4:
                                        this.iArray[2] += this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 4) - 2;
                                        break;
                                    case 5:
                                        //#if NOKIA_S60V5
                                         this.iArray[2] = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 50 + (Constant.FONT_SMALL_HEIGHT + 4) * 4 + this.shTextHeight;
                                        //#else
//#                                        this.iArray[2] = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 40 + (Constant.FONT_SMALL_HEIGHT + 4) * 4 + this.shTextHeight;
                                        //#endif
                                        break;
                                }
                            }
                            if (sNpcName.equals(this.sArray[1])) {
                                Tools.rollIndex = 0;
                                infoHeight = Tools.getParagraphHeight(info[bySelectIndex - 1], 209, 38);
                                rollindex = 0;
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                            if (this.byMaxPage > 1 && this.byPageIndex > 1) {
                                this.byPageIndex = (byte) (this.byPageIndex - 1);
                                this.bySelectIndex = 1;
                                //#if NOKIA_S60V5
//                                 this.iPositionY = this.iArray[2] = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 35 + Constant.FONT_SMALL_HEIGHT + 2 + this.shTextHeight;
                                //#else
//#                                this.iPositionY = this.iArray[2] = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 26 + Constant.FONT_SMALL_HEIGHT + 2 + this.shTextHeight;
                                //#endif
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                            if (this.byMaxPage > 1 && this.byPageIndex < this.byMaxPage) {
                                this.byPageIndex = (byte) (this.byPageIndex + 1);
                                this.bySelectIndex = 1;
                                //#if NOKIA_S60V5
//                                 this.iPositionY = this.iArray[2] = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 35 + Constant.FONT_SMALL_HEIGHT + 2 + this.shTextHeight;
                                //#else
//#                                this.iPositionY = this.iArray[2] = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 26 + Constant.FONT_SMALL_HEIGHT + 2 + this.shTextHeight;
                                //#endif
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                            //发送操作
                            this.sendNPCcmd();
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            this.iPositionY = Tools.updateLinePos(iArray, this.iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bUiKeyPressLock = false;
                            }
                        }
                    }
                }
                break;
            case 2:
                if (byMenuIndex > 3) {
                    this.byState = (byte) ((this.byState == 1) ? 2 : 1);
                    byMenuIndex = 0;
                } else {
                    byMenuIndex++;
                }
                break;
        }

        MainCanvas.clearInput();
    }

    /**
     * 绘制npc对话界面
     * @param g
     */
    public void drawNPCTalk(Graphics g) {
        this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - this.iWidth) >> 1);
        this.iStartY = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1);
        //#if NOKIA_S60V5
         if (this.byTotalNum > 0) {
             Tools.drawPopUp(g, this.byPopUpState, this.iStartX, iStartY, this.iWidth, this.iHeight, this.imgArray[0], 0x9c9c9c, null, 0, 0, 0, 0, null, 0, 0, 0, 0, this.sNpcName, null);
         } else {
             Tools.drawPopUp(g, this.byPopUpState, this.iStartX, iStartY, this.iWidth, this.iHeight, this.imgArray[0], 0x9c9c9c, this.imgArray[1], 22, 0, 21, 10, this.imgArray[1], 0, 0, 22, 10, this.sNpcName, null);
         }
        //#else
//#        if (this.byTotalNum > 0) {
//#            Tools.drawPopUp(g, this.byPopUpState, this.iStartX, iStartY, this.iWidth, this.iHeight, this.imgArray[0], 0x989898, null, 0, 0, 0, 0, null, 0, 0, 0, 0, this.sNpcName, null);
//#        } else {
//#            Tools.drawPopUp(g, this.byPopUpState, this.iStartX, iStartY, this.iWidth, this.iHeight, this.imgArray[0], 0x989898, this.imgArray[1], 0, 0, 22, 10, this.imgArray[1], 22, 0, 21, 10, this.sNpcName, null);
//#        }
        //#endif
        if (this.byPopUpState < 4) {
            return;
        }
        if (this.byUiState == 2) {
            //g.drawString("读取中……", this.iStartX + ((this.iWidth - Constant.FONT_SMALL.stringWidth("读取中……")) >> 1), this.iStartY + ((this.iHeight - Constant.FONT_SMALL_HEIGHT) >> 1), 0);
            iStartX = iStartX + ((this.iWidth - 185) >> 1);
            this.iStartY += ((this.iHeight - 11) >> 1);
            g.drawRegion(this.imgArray[7], 0, 0, 11, 13, Constant.TRANS_NONE, this.iStartX, iStartY, 0);
            g.drawRegion(this.imgArray[7], 0, 0, 11, 13, Constant.TRANS_ROT180, this.iStartX + 174, iStartY, 0);
            Tools.drawTilePic(g, (byte) 1, iStartX + 11, iStartY + 1, 163, this.imgArray[7], 0, 13, 11, 11, Constant.TRANS_NONE);
            if (this.byState == 1) {
                this.iStartX += 14;
                byte byRegionY = 36;
                for (byte i = 1; i <= 10; i++) {
                    g.drawRegion(this.imgArray[7], 0, byRegionY, 13, 3, Constant.TRANS_NONE, this.iStartX, iStartY + 5, 0);
                    if (!Tools.isOdd(i)) {
                        byRegionY -= 3;
                    }
                    this.iStartX += 16;
                }
            } else {
                this.iStartX += 158;
                byte byRegionY = 36;
                for (byte i = 1; i <= 10; i++) {
                    g.drawRegion(this.imgArray[7], 0, byRegionY, 13, 3, Constant.TRANS_NONE, this.iStartX, iStartY + 5, 0);
                    if (!Tools.isOdd(i)) {
                        byRegionY -= 3;
                    }
                    this.iStartX -= 16;
                }
            }
            return;
        }
        //#if NOKIA_S60V5
         this.iStartY += 35;
        //#else
//#        this.iStartY += 26;
        //#endif
        if (this.shTextHeight > 0) {
            //文字段落
            Tools.drawParagraph(g, iStartX + 10, iStartY, this.iWidth - 20, sTalkContent, 0x000000, Constant.FONT_SMALL_HEIGHT, -1);
            this.iStartY += this.shTextHeight;
        }
        boolean need = !MainCanvas.existUI(Constant.GAME_UI_NPC_TALK);

        //绘制任务和功能
        byte byStartIndex = (byte) ((this.byPageIndex - 1) * 4);
        byte byEndIndex = (byte) (this.byPageIndex * 4 > this.byTotalNum ? this.byTotalNum : this.byPageIndex * 4);
        int[][] touchrect = new int[byEndIndex - byStartIndex + 2][];

        for (byte i = byStartIndex; i < byEndIndex; i++) {
            if (this.sNPCTaskFuncArray[4 * i].equals(this.sArray[2])) {
                //任务
                //绘制任务的图标绘制功能功能
                Tools.drawTaskIcon(g, Byte.parseByte(this.sNPCTaskFuncArray[4 * i + 3]), this.imgArray[4], iStartX + ((this.iWidth - Constant.FONT_SMALL.stringWidth(this.sNPCTaskFuncArray[i * 4 + 2]) - 18) >> 1), this.iStartY + ((Constant.FONT_SMALL_HEIGHT - 15) >> 1));
                Tools.drawShadowString(g, (byte) 1, this.sNPCTaskFuncArray[i * 4 + 2], iStartX + ((this.iWidth - Constant.FONT_SMALL.stringWidth(this.sNPCTaskFuncArray[i * 4 + 2]) - 18) >> 1) + 18, this.iStartY, 0xFFFFFF, 0x000000);
            } else if (this.sNPCTaskFuncArray[4 * i].equals(this.sArray[3])) {
                //绘制功能功能
                if (this.sNPCTaskFuncArray[i * 4 + 1].length() >= 10 && this.sNPCTaskFuncArray[i * 4 + 1].substring(0, 8).equals(this.sArray[0])) {
                    Tools.drawShadowString(g, (byte) 1, this.sNPCTaskFuncArray[i * 4 + 2], iStartX + ((this.iWidth - Constant.FONT_SMALL.stringWidth(this.sNPCTaskFuncArray[i * 4 + 2])) >> 1), this.iStartY, 0x00ff99, 0x000000);
                } else {
                    Tools.drawShadowString(g, (byte) 1, this.sNPCTaskFuncArray[i * 4 + 2], iStartX + ((this.iWidth - Constant.FONT_SMALL.stringWidth(this.sNPCTaskFuncArray[i * 4 + 2])) >> 1), this.iStartY, 0xFFFFFF, 0x000000);
                }
            }
            if (need) {
            	touchrect[i-byStartIndex+2]=new int[]{60,iStartY,240,Constant.FONT_SMALL_HEIGHT + 4};
            }
            this.iStartY += (Constant.FONT_SMALL_HEIGHT + 4);
        }
        if (need) {
            touchrect[0] = new int[]{60,iStartY,120,Constant.FONT_SMALL_HEIGHT + 4};
            touchrect[1] = new int[]{180,iStartY,120,Constant.FONT_SMALL_HEIGHT + 4};
        	MainCanvas.putHash(Constant.GAME_UI_NPC_TALK, touchrect);
        }

        //绘制翻页
        if (this.byTotalNum > 4) {
            //#if NOKIA_S60V5
             Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[5], this.imgArray[2], this.iStartX + ((this.iWidth - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 35 + (Constant.FONT_SMALL_HEIGHT + 4) * 4 + this.shTextHeight);
            //#else
//#            Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[5], this.imgArray[2], this.iStartX + ((this.iWidth - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.iHeight) >> 1) + 26 + (Constant.FONT_SMALL_HEIGHT + 4) * 4 + this.shTextHeight);
            //#endif
        }
        //绘制选中线
        if (this.byTotalNum > 0) {
            //#if NOKIA_S60V5
             Tools.drawSelectMask(g, (byte) 1, this.imgArray[3], Constant.UI_START_X, this.iPositionY, Constant.DRAW_WIDTH);
            //#else
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[3], Constant.UI_START_X, this.iPositionY, Constant.DRAW_WIDTH, this.imgArray[2], this.imgArray[6], 0, 0, 24, 12, this.imgArray[6], 49, 0, 23, 12);
            //#endif
        }
        //#if NOKIA_S60V5
         Tools.drawBottom(g, this.imgArray[6], this.imgArray[8], this.imgArray[9]);
        //#endif
        //绘制提示信息
        if (sNpcName.equals(this.sArray[1])) {
            //绘制提示信息背景
            iStartX = Constant.UI_START_X + (Constant.DRAW_WIDTH - 232 >> 1);
            //#if NOKIA_S60V5
             iStartY = Constant.UI_START_Y + Constant.DRAW_HEIGHT - 120;
            //#else
//#            iStartY = Constant.UI_START_Y + Constant.DRAW_HEIGHT - 60;
            //#endif
            //#if NOKIA_E72
//#             g.setColor(0x9c9c9c);
//#             g.fillRect(0, Constant.SCREEN_HEIGHT - Constant.FONT_SMALL_HEIGHT - 4, Constant.SCREEN_WIDTH, Constant.FONT_SMALL_HEIGHT + 4);
//#             Tools.drawShadowString(g, (byte) 1, info[bySelectIndex - 1], Constant.SCREEN_WIDTH - rollindex, Constant.SCREEN_HEIGHT - Constant.FONT_SMALL_HEIGHT - 2, 0xFFFFFF, 0x000000);
//#             rollindex += 3;
//#             if (Constant.SCREEN_WIDTH - rollindex + Constant.FONT_SMALL.stringWidth(info[bySelectIndex - 1]) + 10 < 0) {
//#                 rollindex = 0;
//#             }
            //#else
            iWidth = 232;
            Tools.drawRoundRect(g, this.imgArray[0], 0x9c9c9c, iWidth, 56, iStartX, iStartY);
            //绘制提示信息内容
            iStartX += 10;
            iStartY += 8;
            Tools.drawHCycleRollingParagraph(g, info[bySelectIndex - 1], infoHeight, iWidth - (14 << 1), 38, 16, iStartX, iStartY, 0xFFFFFF, 0x000000);
            //#endif
        }
    }
    public void checkTouchNPCTalk(int x, int y) {
		Integer key = new Integer(MainLogic.getInstance().byGameState); 
		int[][]touchrect = (int[][]) MainCanvas.s_uiTouch.get(key);
		if (touchrect == null)
			return;
		int touched =  MainCanvas.checkTouch(x, y, touchrect);
		if (touched >= 0) {
			if (touched == 0) {
				 MainCanvas.pressDir(2);
			} else if (touched == 1) {
				 MainCanvas.pressDir(3);
			} else {
				touched -=1;
				NPCTalk npcTalk = MainLogic.getInstance().uiInterFace.npcTalk;
		        if (npcTalk.bySelectIndex == touched) {
		        	 MainCanvas.pressFire();
		        } else {
		        	if(npcTalk.bySelectIndex > touched) {//向上
		        		npcTalk.bySelectIndex = (byte) (touched + 1);
		        		 MainCanvas.pressDir(0);
		        	} else {
		        		npcTalk.bySelectIndex = (byte) (touched - 1);
		        		 MainCanvas.pressDir(1);
		        	}
		        }
			}
		} else {
			 MainCanvas.checkSoftKey();
		}		
	}
    private static int rollindex;

    /**
     * 清除npc对话界面资源
     */
    public void clearNPCTalk() {
        this.imgArray = null;
        this.byTaskState = null;
        this.sNPCTaskFuncArray = null;
        this.sTalkContent = null;
        this.iArray = null;
        this.sArray = null;
        this.sNpcName = null;
        info = null;
        this.bySingleTaskState = -1;
    }

    //根据用户的选择来向服务器发送请求数据
    private void sendNPCcmd() {
        if (this.byTotalNum <= 0) {
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (this.bySelectIndex == 5) {
            return;
        }
        byte byTaskFuncIndex = (byte) ((this.byPageIndex - 1) * 4 + this.bySelectIndex - 1);
        if (byTaskFuncIndex >= this.byTotalNum) {
            return;
        }
        if (this.sNPCTaskFuncArray[4 * byTaskFuncIndex].equals("t")) {
            if (GameBean.BY_SCENE == 2) {
                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "只有本帮成员才可以进行操作");
                return;
            } else {
                //任务
                if (Byte.parseByte(this.sNPCTaskFuncArray[byTaskFuncIndex * 4 + 3]) == 0) {
                    GameBean.SH_CMD_QUEST = 1;
                } else {
                    GameBean.SH_CMD_QUEST = 2;
                }
                GameBean.L_NPC_ID = this.lNPCID;
                this.sTaskKey = this.sNPCTaskFuncArray[byTaskFuncIndex * 4 + 1];
                GameBean.STR_CMD_QUEST_KEY = this.sTaskKey;
                Tools.printLog("GameBean.STR_CMD_QUEST_KE=" + GameBean.STR_CMD_QUEST_KEY);
                GameBean.b_WAIT_NET_MSG_BACK = true;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST, Constant.SOCKET_MSG_TYPE_LOGIC);
            }
        } else if (this.sNPCTaskFuncArray[4 * byTaskFuncIndex].equals("f")) {
            //功能
            GameBean.L_NPC_ID = this.lNPCID;
            this.funcCommand(this.sNPCTaskFuncArray[byTaskFuncIndex * 4 + 1]);
        }
    }

    /**
     * 功能
     * @param key
     */
    private void funcCommand(String key) {
        Tools.printLog("key=" + key);
        if (key.equals("compose")) {
            //合成
            MainLogic.getInstance().pushState(Constant.GAME_UI_ITEMS_COMPOSE, true);
        } else if (key.equals("decompose")) {
            //分解
            MainLogic.getInstance().pushState(Constant.GAME_UI_ITEMS_DECOMPOSE, true);
        } else if (key.equals("strength")) {
            //强化
            MainLogic.getInstance().pushState(Constant.GAME_UI_ITEMS_STRENGTHEN, true);
        } else if (key.equals("petCompose")) {
            //宠物合成
            MainLogic.getInstance().pushState(Constant.GAME_UI_PET_COMPOSE, true);
        } else if (key.equals("buyItems")) {
            if (GameBean.BY_SCENE == 2) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "不能在其他帮派的帮派家园中打开商店!", (byte) 1, (byte) -1);
            } else {
                //购买东西
                GameBean.b_WAIT_NET_MSG_BACK = true;
                GameBean.L_NPC_ID = this.lNPCID;
                MainLogic.getInstance().uiInterFace.store.lNpcID = this.lNPCID;
                //打开普通的npc商店
                GameBean.BY_OP_TYPE = 1;
                Tools.printLog("发送购买东西");
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_NPC_STORE, Constant.SOCKET_MSG_TYPE_LOGIC);
                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
            }
        } else if (key.equals("soldItems")) {
            if (GameBean.BY_SCENE == 2) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "不能在其他帮派的帮派家园中出售物品!", (byte) 1, (byte) -1);
            } else {
                //出售物品
                GameBean.L_NPC_ID = this.lNPCID;
                MainLogic.getInstance().pushState(Constant.GAME_UI_STORE_SOLD, true);
            }
        } else if (key.equals("depot")) {
            if (GameBean.BY_SCENE == 2) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "不能在其他帮派的帮派家园中打开仓库!", (byte) 1, (byte) -1);
            } else {
                GameBean.L_NPC_ID = this.lNPCID;
                GameBean.b_WAIT_NET_MSG_BACK = true;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_DEPOT, Constant.SOCKET_MSG_TYPE_LOGIC);
            }
        } else if (key.equals("repairSystemicEquipment")) {
            if (GameBean.BY_SCENE == 2) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "不能在其他帮派的帮派家园中修理装备!", (byte) 1, (byte) -1);
            } else {
                //修理全身装备装备
                GameBean.BY_TYPE = 1;
                GameBean.SH_MIN_PET_REPAIR_LEVLE = 0;
                GameBean.SH_MAX_PET_REPAIR_LEVLE = 0;
                GameBean.b_WAIT_NET_MSG_BACK = true;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_GET_REPAIR_FEE, Constant.SOCKET_MSG_TYPE_LOGIC);
                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
            }
        } else if (key.equals("repairPackageEquipment")) {
            if (GameBean.BY_SCENE == 2) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "不能在其他帮派的帮派家园中修理装备!", (byte) 1, (byte) -1);
            } else {
                //修理背包装备装备
                GameBean.b_WAIT_NET_MSG_BACK = true;
                GameBean.BY_TYPE = 2;
                GameBean.SH_MIN_PET_REPAIR_LEVLE = 0;
                GameBean.SH_MAX_PET_REPAIR_LEVLE = 0;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_GET_REPAIR_FEE, Constant.SOCKET_MSG_TYPE_LOGIC);
                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
            }
        } else if (key.equals("soldWhiteEquipment")) {
            if (GameBean.BY_SCENE == 2) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "不能在其他帮派的帮派家园中出售装备!", (byte) 1, (byte) -1);
            } else {
                //出售白色装备
                GameBean.b_WAIT_NET_MSG_BACK = true;
                GameBean.BY_TYPE = 3;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_REPAIR, Constant.SOCKET_MSG_TYPE_LOGIC);
            }
        } else if (key.equals("hole_inlay_dismantle")) {
            MainLogic.getInstance().pushState(Constant.GAME_UI_EQUIP_OPERATION, true);
        } else if (key.equals("tong_list")) {//帮派列表
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_TONG_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
        } else if (key.equals("tong_create")) {//创建帮派
            if (MainLogic.getInstance().gamePlayer.sTongName == null) {
                MainLogic.getInstance().pushState(Constant.GAME_UI_CREATE_TONG, true);
            } else {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您目前已有帮派!", (byte) 1, (byte) -1);
            }
        } else if (key.equals("tong_trans")) {//帮派传送
            if (MainLogic.getInstance().gamePlayer.sTongName == null) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您目前没有帮派!", (byte) 0, Constant.GAME_UI_ROAM);
            } else {
                GameBean.b_WAIT_NET_MSG_BACK = true;
                GameBean.L_CMD_TONG_ID = MainLogic.getInstance().gamePlayer.lTongId;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_TONG_TRANS, Constant.SOCKET_MSG_TYPE_LOGIC);
            }
        } else if (key.equals("tong_dismiss")) {//帮派解散
            if (MainLogic.getInstance().gamePlayer.sTongName == null) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您目前还有帮派!", (byte) 0, Constant.GAME_UI_ROAM);
            } else {
                if (MainLogic.getInstance().gamePlayer.bTongDuty == 4) {
                    GameBean.BY_CMD_TONG_DIMISS = 1;
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您确认要解散帮派吗！|帮派解散后仓库中的物品将会被清空", (byte) 0, Constant.GAME_UI_ROAM);
                } else {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "只有帮主才有解散帮派的权限!", (byte) 1, (byte) -1);
                }
            }
        } else if (key.equals("tong_build")) {//帮派建造
            if (GameBean.BY_SCENE == 2) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "不能在其他帮派的帮派家园中进行该操作!", (byte) 1, (byte) -1);
            } else {
                GameBean.b_WAIT_NET_MSG_BACK = true;
                MainLogic.getInstance().send(Constant.MSG_NET_TONG_NPC_INFO, Constant.SOCKET_MSG_TYPE_LOGIC);
            }
        } else if (key.equals("tong_descript")) {//修改公告
            if (GameBean.BY_SCENE == 2) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "不能在其他帮派的帮派家园中进行该操作!", (byte) 1, (byte) -1);
            } else if (MainLogic.getInstance().gamePlayer.bTongDuty < 2) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "权限不够!", (byte) 1, (byte) -1);
            } else {
                MainLogic.inputInterFace.setInputInterFace((byte) 1, "修改公告");
                MainGame.changeCanvas(MainLogic.inputInterFace);
            }
        } else if (key.equals("tong_info")) {//帮派信息
            GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_NPC_TALK;
            GameBean.L_CMD_TONG_ID = 0;
            GameBean.b_WAIT_NET_MSG_BACK = true;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_TONG_DESCRIPT, Constant.SOCKET_MSG_TYPE_LOGIC);
        } else if (key.equals("tong_trans_out")) {//帮派传出
            GameBean.L_CMD_TONG_ID = 0;
            GameBean.b_WAIT_NET_MSG_BACK = true;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_TONG_TRANS, Constant.SOCKET_MSG_TYPE_LOGIC);
        } else if (key.equals("send")) {
            GameBean.b_WAIT_NET_MSG_BACK = true;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_GET_SEND_POINT, Constant.SOCKET_MSG_TYPE_LOGIC);
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (key.equals("taozhuang")) {
            //牌子兑换d
            //购买东西
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.L_NPC_ID = this.lNPCID;
            //打开普通的npc商店
            GameBean.BY_OP_TYPE = 2;
            Tools.printLog("发送牌子兑换东西");
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_NPC_STORE, Constant.SOCKET_MSG_TYPE_LOGIC);
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (key.equals("bangpaihuiji")) {
            //徽记兑换
            //购买东西
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.L_NPC_ID = this.lNPCID;
            //打开普通的npc商店
            GameBean.BY_OP_TYPE = 3;
            Tools.printLog("发送徽记兑换东西");
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_NPC_STORE, Constant.SOCKET_MSG_TYPE_LOGIC);
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (key.equals("applyTongArena")) {
            //冰风源军官报名
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.BY_TYPE = 1;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_APPLY_TONG_ARENA, Constant.SOCKET_MSG_TYPE_LOGIC);
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (key.equals("getApplyTongList")) {
            //冰风源军官查看报名结构
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.BY_CMD_APPLY_FIGHT_TYPE = 1;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_GET_APPLY_TONG_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
        } else if (key.equals("sendTongArena")) {
            //冰风源军官战场传送
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.BY_TYPE = 1;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_SEND_TONG_ARENA, Constant.SOCKET_MSG_TYPE_LOGIC);
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (key.equals("applyTongArenas")) {
            //落日古军官报名
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.BY_TYPE = 2;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_APPLY_TONG_ARENA, Constant.SOCKET_MSG_TYPE_LOGIC);
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (key.equals("getApplyTongLists")) {
            //落日古军官查看报名结构
//            Tools.printLog("客户端ui还没有做");
//            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "客户端ui还没有做");
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.BY_CMD_APPLY_FIGHT_TYPE = 2;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_GET_APPLY_TONG_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
        } else if (key.equals("sendTongArenas")) {
            //落日古军官战场传送
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.BY_TYPE = 2;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_SEND_TONG_ARENA, Constant.SOCKET_MSG_TYPE_LOGIC);
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (key.equals("reciveMailBox")) {
            GameBean.b_WAIT_NET_MSG_BACK = true;
            MainLogic.getInstance().uiEquipment.Opeartion_type = 7;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_MAIL_OPEARTION, Constant.SOCKET_MSG_TYPE_LOGIC);
            //打开收件箱
        } else if (key.equals("sendMailBox")) {
            MainLogic.getInstance().uiEquipment.initSendMail();
            MainLogic.getInstance().pushState(Constant.GAME_UI_SEND_EMAIL, true);
            Constant.CMD_MAIL_TYPE = 0;

            //打开发件箱
        } else if (key.equals("send1")) {
            //传送到痛苦堡垒
            GameBean.b_WAIT_NET_MSG_BACK = true;
            if (MainLogic.getInstance().gamePlayer.iPlayerLevel >= 13) {
                this.send("10301", 0, 0);
            } else {
                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您需要到13级才可以进入");
            }
        } else if (key.equals("send2")) {
            //传送到幽暗迷宫
            if (MainLogic.getInstance().gamePlayer.iPlayerLevel >= 25) {
                GameBean.b_WAIT_NET_MSG_BACK = true;
                this.send("10401", 0, 0);
            } else {
                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "需要到25级才可以进入");
            }

        } else if (key.equals("kaifazu")) {
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.L_NPC_ID = this.lNPCID;
            GameBean.BY_OP_TYPE = 5;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_NPC_STORE, Constant.SOCKET_MSG_TYPE_LOGIC);
//            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
//            System.out.println("kaifazu  ");

        } else if (key.equals("linglongta")) {
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.L_NPC_ID = this.lNPCID;
            GameBean.BY_OP_TYPE = 6;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_NPC_STORE, Constant.SOCKET_MSG_TYPE_LOGIC);
//            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
//            System.out.println("linglongta  ");
        } else if (key.equals("huanmojing")) {
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.L_NPC_ID = this.lNPCID;
            GameBean.BY_OP_TYPE = 4;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_NPC_STORE, Constant.SOCKET_MSG_TYPE_LOGIC);
//            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
//            System.out.println("huanmojing  ");
        } else if (key.equals("send3")) {
            //传送到龙脉皇陵
            if (MainLogic.getInstance().gamePlayer.iPlayerLevel >= 33) {
                GameBean.b_WAIT_NET_MSG_BACK = true;
                this.send("10501", 0, 0);
            } else {
                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "需要到33级才可以进入");
            }
        } else if (key.equals("question")) {//答题
            GameBean.BY_QUESTION = 1;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUESTION_INFO, Constant.SOCKET_MSG_TYPE_LOGIC);
        } else if (key.equals("fuxi")) {//打卡
            MainLogic.getInstance().pushState(Constant.GAME_UI_PUNCH_CLOCK, true);
        } else if (key.length() > 9 && key.substring(0, 9).equals("shuoming_")) {
            GameBean.b_WAIT_NET_MSG_BACK = false;
            this.openFuncDesc(this.sNPCTaskFuncArray[((this.byPageIndex - 1) * 4 + this.bySelectIndex - 1) * 4 + 2], key);
        } else if (key.equals("hangUp")) {
            if (MainLogic.getInstance().gamePlayer.iPlayerLevel < 30) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "只有30级及以上玩家才能开启离线挂机功能!", (byte) 1, (byte) -1);
            } else {
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_HANGUP_START, Constant.SOCKET_MSG_TYPE_LOGIC);
            }
        } else if (key.equals("change")) {
            GameBean.b_WAIT_NET_MSG_BACK = false;
            GameBean.L_NPC_ID = this.lNPCID;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_NPC_CHANGE, Constant.SOCKET_MSG_TYPE_LOGIC);
        } else if (key.equals("activation")) {//用户使用激活码
            MainLogic.inputInterFace.setInputInterFace((byte) 0, "请输入您的激活码:");
            MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
        }
    }
    /********************************任务列表界面********************************************************************************************/
    public String[][] sTaskList;

    /**************************装被修理********************************************************************/
    /**
     * 修理装备
     */
    public void initRepairEquip() {
        //弹出层的标题
        try {
            //弹出层的图片数组
            // color = 0xccb5a1;
            //图片资源
            //背景颜色层
            //#if NOKIA_S60V5
             this.imgArray = new Image[5];
             this.imgArray[0] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
             this.imgArray[1] = ResManager.createImage(90000044);
             this.imgArray[2] = ResManager.createImage(90000043);//文字
             this.imgArray[3] = ResManager.createImage(90000086);
             this.imgArray[4] = ResManager.createImage(90000090);
            //#else
//#            this.imgArray = new Image[2];
//#            this.imgArray[0] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
//#            this.imgArray[1] = ResManager.createImage(90000044);
            //#endif
            //确定  
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
//            System.out.print("弹出层图片载入异常");
        }
    }

    /************************************************修理装备****************************************************/
    /**
     * 打开修理装备
     * @param lMoney
     */
    public void openRepairEquip(long lMoney, byte byRepairType) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        this.byRepairType = byRepairType;
        this.lMoney = lMoney;
        this.sArray = new String[]{"装备修理", "修理费用：" + Tools.moneyConvert(lMoney) + "!,您确认要修理么?"};
        MainLogic.getInstance().pushState(Constant.GAME_UI_EQUIP_REPAIR, true);
    }

    /*
     * *修理完成
     * @param stateCode
     */
    public void repairEquip(byte stateCode) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                if (GameBean.BY_TYPE == 3) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "装备出售失败!");
                } else {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "装备修理失败!");
                }
                break;
            case 1:
                if (GameBean.BY_TYPE == 3) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "装备出售成功!");
                } else {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "装备修理成功!");
                }
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "修理全身装备金钱不足");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "修理背包装备金钱不足");
                break;
        }
    }

    /**
     * 更新修理装备
     */
    public void updateRepairEquip() {
        if (this.byState < 4) {
            this.byState++;
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
            GameBean.BY_TYPE = this.byRepairType;
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_REPAIR, Constant.SOCKET_MSG_TYPE_LOGIC);
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        }
        MainCanvas.clearInput();
    }

    /**
     * 绘制修理装备
     */
    public void drawRepairEquip(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawPopUp(g, this.byState, Constant.UI_START_X + 25, Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 120) >> 1), 310, 120, this.imgArray[0], 0x9c9c9c, this.imgArray[1], 22, 0, 21, 10, this.imgArray[1], 0, 0, 22, 10, this.sArray[0], this.sArray[1]);
         Tools.drawBottom(g, this.imgArray[2], this.imgArray[4], this.imgArray[3]);
        //#else
//#        Tools.drawPopUp(g, this.byState, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 80) >> 1), 232, 80, this.imgArray[0], 0x989898, this.imgArray[1], 0, 0, 22, 10, this.imgArray[1], 22, 0, 21, 10, this.sArray[0], this.sArray[1]);
        //#endif
    }

    /**
     * 清除修理装备资源
     */
    public void clearRepairEquip() {
        this.imgArray = null;
        this.sArray = null;
        this.bySingleTaskState = -1;
    }

    /**
     * 传送
     */
    public void send(String sScenceKey, int iPosX, int iPosY) {
        GameBean.STR_SCENCE_KEY = sScenceKey;
        GameBean.i_SEND_POS_X = iPosX;
        GameBean.i_SEND_POS_Y = iPosY;
        Tools.printLog("GameBean.STR_SCENCE_KEY, GameBean.i_SEND_POS_X , GameBean.i_SEND_POS_X=" + GameBean.STR_SCENCE_KEY + "|" + GameBean.i_SEND_POS_X + "|" + GameBean.i_SEND_POS_Y + "|");
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_SEND, Constant.SOCKET_MSG_TYPE_LOGIC);
        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
    }

    /**************任务完成后自动寻路************************************/
    public void openTaskAutoFindPath(String sTaskTitle, String sScenceKey, int x, int y) {
        this.sArray = new String[]{"任务完成提示", "任务：“" + sTaskTitle + "”已经完成，是否开始寻路归还任务?", sScenceKey, String.valueOf(x), String.valueOf(y)};
        MainLogic.getInstance().pushState(Constant.GAME_UI_TASK_AUTO_FIND_PATH, true);
    }

    public void initTaskAutoFindPath() {
        this.byPopUpState = 1;
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[5];
 
             this.imgArray[0] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
             this.imgArray[1] = ResManager.createImage(90000044);
             this.imgArray[2] = ResManager.createImage(90000043);//文字
             this.imgArray[3] = ResManager.createImage(90000086);
             this.imgArray[4] = ResManager.createImage(90000090);
            //#else
//#            this.imgArray = new Image[2];
//#            this.imgArray[0] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
//#            this.imgArray[1] = ResManager.createImage(90000044);
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        //#if  NOKIA_S60V5
         this.iHeight = Tools.getParagraphHeight(this.sArray[1], 290, Constant.FONT_SMALL_HEIGHT + 2) + 50;
         if (this.iHeight < 120) {
             this.iHeight = 120;
         }
        //#else
//#        this.iHeight = Tools.getParagraphHeight(this.sArray[1], 212, Constant.FONT_SMALL_HEIGHT + 2) + 40;
//#        if (this.iHeight < 80) {
//#            this.iHeight = 80;
//#        }
        //#endif
    }

    public void updateTaskAutoFindPath() {
        if (this.byPopUpState < 4) {
            this.byPopUpState++;
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
            Tools.printLog("this.sArray[2]=" + this.sArray[2] + "#Integer.parseInt(this.sArray[3])=" + Integer.parseInt(this.sArray[3]) + "Integer.parseInt(this.sArray[4])=" + Integer.parseInt(this.sArray[4]));
            MainLogic.getInstance().gamePlayer.stopAutoRun(false, true);
            MainLogic.getInstance().clearLockedObj(0, true);
            MainLogic.getInstance().gamePlayer.runPathFinderForMission(this.sArray[2], Integer.parseInt(this.sArray[3]), Integer.parseInt(this.sArray[4]));
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
            //不寻路
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        }
        MainCanvas.clearInput();
    }

    public void drawTaskAutoFindPath(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + 25, Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 120) >> 1), 310, this.iHeight, this.imgArray[0], 0x9c9c9c, this.imgArray[1], 22, 0, 21, 10, this.imgArray[1], 0, 0, 22, 10, this.sArray[0], this.sArray[1]);
         Tools.drawBottom(g, this.imgArray[2], this.imgArray[4], this.imgArray[3]);
        //#else
//#        Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 80) >> 1), 232, this.iHeight, this.imgArray[0], 0x989898, this.imgArray[1], 0, 0, 22, 10, this.imgArray[1], 22, 0, 21, 10, this.sArray[0], this.sArray[1]);
        //#endif

    }

    public void clearTaskAutoFindPath() {
        this.sArray = null;
        this.imgArray = null;
        this.bySingleTaskState = -1;
    }

    /********************************************任务列表***********************************************************/
    public void openTaskList(byte byType) {
        GameBean.BY_TYPE = byType;
        if (byType == 2) {
            this.bySingleTaskState = -1;
        }
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
    }

    public void openTaskList() {
        if (this.byPreTaskType != -1 && this.sPreTaskKey != null) {
            if (this.byPreTaskType == 2 || this.byPreTaskType == 3) {
                openTaskList((byte) 1);
            } else {
                openTaskList((byte) 0);
            }
        } else {
            openTaskList((byte) 0);
        }
    }

    public void setTaskList(String[] sTaskList, byte byTaskType, byte byMainCanAcceptTaskType) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        //#if NOKIA_S60V5
         this.byNumPerPage = 10;
         this.iStartPointY = 60;
        //#elif NOKIA_E72
//#         this.iStartPointY = 24;
//#         this.byNumPerPage = 6;
        //#else
//#        this.iStartPointY = 30;
//#        this.byNumPerPage = 8;
        //#endif
        if (MainLogic.getInstance().byGameState != Constant.GAME_UI_TASK_LIST) {
            //0：表示还没有从服务器获得列表;1:表示已经获得
            this.byTaskState = new byte[]{0, 0, 0};
            this.sTaskList = new String[3][];
            MainLogic.getInstance().pushState(Constant.GAME_UI_TASK_LIST, true);
        }
        this.sTaskList[byTaskType] = sTaskList;
        if (byTaskType == 2) {
            this.bySingleTaskState = byMainCanAcceptTaskType;
        }
        this.byTotalNum = (byte) (this.sTaskList[byTaskType] != null ? (short) (this.sTaskList[byTaskType].length / 8) : 0);
        if (byTotalNum > 0) {
            this.byMaxPage = (byte) Tools.ceil(byTotalNum, this.byNumPerPage);
        } else {
            this.byMaxPage = 1;
        }
        this.byTabIndex = (byte) (byTaskType + 1);
        this.byTaskState[byTaskType] = 1;
        this.sArray[8] = this.byTabIndex == 3 ? "去接任务" : "放弃任务";
        boolean bDefaultSet = true;
        if (this.byPreTaskType != -1 && this.sPreTaskKey != null && byTotalNum > 0) {
            if (((this.byPreTaskType == 2 || this.byPreTaskType == 3) && byTaskType == 1) || ((this.byPreTaskType != 2 && this.byPreTaskType != 3) && byTaskType == 0)) {
                //找到key位置设置
                for (byte i = 0; i < byTotalNum; i++) {
                    //hlw
                    if (this.sPreTaskKey.equals(this.sTaskList[byTaskType][8 * i])) {
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        bDefaultSet = false;
                        this.byPageIndex = (byte) Tools.ceil(i + 1, this.byNumPerPage);
                        GameBean.BY_TYPE = (byte) (this.byTabIndex - 1);
                        this.bySelectIndex = (byte) (i + 2 - (this.byPageIndex - 1) * this.byNumPerPage);
                        this.iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 10 + (Constant.FONT_SMALL_HEIGHT + 2) * (bySelectIndex - 1);
                        GameBean.STR_CMD_QUEST_KEY = this.sPreTaskKey;
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_SIMPLE_INFO, Constant.SOCKET_MSG_TYPE_LOGIC);
                        break;
                    }
                }
            }
        }
        if (bDefaultSet) {
            this.bySelectIndex = 1;
            this.byPageIndex = 1;
        }
    }

    public void setTaskTarget(String sTaskTarget, byte byTaskType) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        this.sTaskList[byTaskType][((this.byPageIndex - 1) * this.byNumPerPage + this.bySelectIndex - 2) * 8 + 3] = sTaskTarget;
    }
    /**
     * 初始化任务列表界面
     */
    public String[] sTaskPreArray;

    public void initTaskList() {
        /*********************/
//        this.byTaskState = new byte[]{1, 1, 1};
//        this.sTaskList = new String[3][];
//        this.sTaskList[0] = new String[]{"12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222"};
//        this.sTaskList[1] = new String[]{"12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222"};
//        this.sTaskList[2] = new String[]{"12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222", "12342", "下山打老虎", "【23】", "eeeeeeee大商店|eeeeeeee大商店|eeeeeeee大商店", "98882", "122", "2222"};
//        this.byTotalNum = this.sTaskList[0] != null ? (byte) (this.sTaskList[0].length / 7) : 0;
//        this.bySingleTaskState = 0;
//        //#if NOKIA_S60V5
//        this.byNumPerPage = 10;
//        this.iStartPointY = Constant.UI_START_Y + 50;
//        //#elif NOKIA_E72
////#         this.iStartPointY = Constant.UI_START_Y + 23;
////#         this.byNumPerPage = 5;
//        //#else
////#         this.iStartPointY = Constant.UI_START_Y + 30;
////#         this.byNumPerPage = 8;
//        //#endif
//        if (byTotalNum > 0) {
//            this.byMaxPage = (byte) Tools.ceil(byTotalNum, this.byNumPerPage);
//        } else {
//            this.byMaxPage = 1;
//        }
//        this.byTabIndex = 1;
//        this.iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 10 + Constant.FONT_SMALL_HEIGHT + 3;
        /*************************************************/
        GameBean.b_WAIT_NET_MSG_BACK = false;
        this.byUiState = 0;
        this.bUiKeyPressLock = false;
        this.byPopUpState = 1;
        this.sArray = new String[]{"任务查询", "1未完成", "2已完成", "3可接", "请选择", "提示", "您确定要放弃该任务么?", "返回", "去接任务", "完成情况:失败"};
        sTaskPreArray = new String[]{"主线 - ", "支线 - ", "日常 - ", "帮派 - ", "副本 - ", "活动 - "};
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[11];
             this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
             this.imgArray[2] = Tools.makeTransparent(ResManager.createImage(90000051), 255);            //弹出层边框
             this.imgArray[3] = Tools.makeTransparent(Constant.SCREEN_WIDTH, 20, 200, 0x000000);            //背景遮罩层
             this.imgArray[4] = ResManager.createImage(90000043);            //查看确定图片
             this.imgArray[5] = ResManager.createImage(90000017);            //背景图片
             this.imgArray[6] = ResManager.createImage(90000047);//大数字图片
             this.imgArray[7] = ResManager.createImage(90000044);            //白色确定
             this.imgArray[8] = ResManager.createImage(90000084);            //方向键
             this.imgArray[9] = ResManager.createImage(90000085);            //确定
             this.imgArray[10] = ResManager.createImage(90000086);            //蓝条
            //#else
//#            this.imgArray = new Image[8];
//#            this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
//#            this.imgArray[2] = Tools.makeTransparent(ResManager.createImage(90000051), 255);            //弹出层边框
//#            this.imgArray[3] = Tools.makeTransparent(Constant.SCREEN_WIDTH, 20, 200, 0x000000);            //背景遮罩层
//#            this.imgArray[4] = ResManager.createImage(90000043);            //查看确定图片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[5] = ResManager.createImage(90000017);
//# //            imgArray[5] = Tools.ZoomImage(imgArray[5], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[5] = ResManager.createImage(90000017);            //背景图片
            //#endif
//#            this.imgArray[6] = ResManager.createImage(90000047);//大数字图片
//#            this.imgArray[7] = ResManager.createImage(90000044);            //白色确定
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
            Tools.printLog("初始化任务列表界面出错");
        }
    }

    public void insertTask() {
        switch (GameBean.BY_PRE_GAME_UI_STATE) {
            case Constant.GAME_UI_CHAT:
                if (this.bySelectIndex > 1 && this.bySelectIndex < 10) {
                    GameBean.STR_CMD_QUEST_KEY = this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 0);
                    MainLogic.getInstance().uiEquipment.taskORitems_ID[0] = GameBean.STR_CMD_QUEST_KEY;
                    MainLogic.getInstance().uiEquipment.taskORitems_ID[1] = "[" + this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 1) + "]";
                    MainLogic.getInstance().uiEquipment.taskORitems_ID[2] = "" + 1;
                    MainLogic.getInstance().uiEquipment.taskORitems_ID[3] = "1";
                    if (MainLogic.getInstance().uiEquipment.taskORitems_ID[0] != null) {
                        MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, true);
                        MainLogic.getInstance().uiEquipment.taskORitems_new = "*"
                                + MainLogic.getInstance().uiEquipment.taskORitems_ID[0] + "<"
                                + MainLogic.getInstance().uiEquipment.taskORitems_ID[1] + ">"
                                + MainLogic.getInstance().uiEquipment.taskORitems_ID[2] + "$"
                                + MainLogic.getInstance().uiEquipment.taskORitems_ID[3] + "@";
                        MainLogic.getInstance().inputInterFace.commonInput.setString(
                                MainLogic.getInstance().inputInterFace.commonInput.getString() + "/%");
                        //MainGame.changeCanvas(MainLogic.inputInterFace.inputInterTask);
                        MainGame.changeCanvas(MainLogic.getInstance().inputInterFace.inputInterTask);
                        GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT;
                    }
                }
                break;
        }
    }

    public void taskQuickSelect(byte destTab) {
        if (this.byTabIndex == destTab) {
            return;
        }
        this.sArray[8] = destTab == 3 ? "去接任务" : "放弃任务";
        if (this.byTaskState[destTab - 1] == 0) {
            GameBean.b_WAIT_NET_MSG_BACK = true;
            GameBean.BY_TYPE = (byte) (destTab - 1);
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
        } else {
            this.byTabIndex = destTab;
            if (this.sTaskList[this.byTabIndex - 1] != null) {
                this.byTotalNum = (byte) (this.sTaskList[destTab - 1].length / 8);
                this.byMaxPage = (byte) Tools.ceil(this.byTotalNum, this.byNumPerPage);
                this.bySelectIndex = 2;
                this.iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 10 + (bySelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT + 2);
                if (this.sTaskList[this.byTabIndex - 1][((this.byPageIndex - 1) * this.byNumPerPage + this.bySelectIndex - 2) * 8 + 3] == null) {
                    GameBean.b_WAIT_NET_MSG_BACK = true;
                    GameBean.BY_TYPE = (byte) (this.byTabIndex - 1);
                    GameBean.STR_CMD_QUEST_KEY = this.sTaskList[this.byTabIndex - 1][((this.byPageIndex - 1) * this.byNumPerPage + this.bySelectIndex - 2) * 8];
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_SIMPLE_INFO, Constant.SOCKET_MSG_TYPE_LOGIC);
                }
            } else {
                this.byTotalNum = 0;
                this.byMaxPage = 1;
                this.bySelectIndex = 1;
                this.iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 5;
                ;
            }

        }
    }

    /**
     * 更新任务列表界面
     */
    public void updateTaskList() {
        if (!GameBean.b_WAIT_NET_MSG_BACK) {
            switch (this.byUiState) {
                case 0:
                    if (!bUiKeyPressLock) {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                            if (bySelectIndex > 1) {
                                this.byState = 1;
                                bySelectIndex -= 1;
                                this.bUiKeyPressLock = true;
                                if (bySelectIndex > 1) {
                                    this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 10 + (bySelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT + 2), 2, 150, 5};
                                }
                                if (this.bySelectIndex > 1 && this.sTaskList[this.byTabIndex - 1][((this.byPageIndex - 1) * this.byNumPerPage + this.bySelectIndex - 2) * 8 + 3] == null) {
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    GameBean.BY_TYPE = (byte) (this.byTabIndex - 1);
                                    GameBean.STR_CMD_QUEST_KEY = this.sTaskList[this.byTabIndex - 1][((this.byPageIndex - 1) * this.byNumPerPage + this.bySelectIndex - 2) * 8];
                                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_SIMPLE_INFO, Constant.SOCKET_MSG_TYPE_LOGIC);
                                }
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                            if (this.bySelectIndex < this.byNumPerPage + 1 && this.byTotalNum > 0 && this.byTotalNum > (this.byPageIndex - 1) * this.byNumPerPage + (this.bySelectIndex - 1)) {
                                this.byState = 2;
                                this.bySelectIndex += 1;
                                this.bUiKeyPressLock = true;
                                if (bySelectIndex > 1) {
                                    this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 10 + (bySelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT + 2), 2, 150, 5};
                                }
                                if (this.bySelectIndex > 1 && this.sTaskList[this.byTabIndex - 1] != null && this.sTaskList[this.byTabIndex - 1][((this.byPageIndex - 1) * this.byNumPerPage + this.bySelectIndex - 2) * 8 + 3] == null) {
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    GameBean.BY_TYPE = (byte) (this.byTabIndex - 1);
                                    GameBean.STR_CMD_QUEST_KEY = this.sTaskList[this.byTabIndex - 1][((this.byPageIndex - 1) * this.byNumPerPage + this.bySelectIndex - 2) * 8];
                                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_SIMPLE_INFO, Constant.SOCKET_MSG_TYPE_LOGIC);
                                }
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                            if (this.bySelectIndex == 1) {
                                this.byTabIndex = (byte) (this.byTabIndex == 1 ? 3 : this.byTabIndex - 1);
                                if (this.byTaskState[this.byTabIndex - 1] == 0) {
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    GameBean.BY_TYPE = (byte) (this.byTabIndex - 1);
                                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
                                } else {
                                    this.byPageIndex = 1;
                                    if (this.sTaskList[this.byTabIndex - 1] != null) {
                                        this.byTotalNum = (byte) (this.sTaskList[this.byTabIndex - 1].length / 8);
                                        this.byMaxPage = (byte) Tools.ceil(this.byTotalNum, this.byNumPerPage);
                                    } else {
                                        this.byTotalNum = 0;
                                        this.byMaxPage = 1;
                                    }
                                    this.iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 3;
                                    this.bySelectIndex = 1;
                                    this.sArray[8] = this.byTabIndex == 3 ? "去接任务" : "放弃任务";
                                }

                            } else if (this.byPageIndex > 1) {
                                this.byPageIndex = (byte) (this.byPageIndex - 1);
                                this.iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 10 + Constant.FONT_SMALL_HEIGHT + 2;
                                this.bySelectIndex = 2;
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                            if (this.bySelectIndex == 1) {
                                this.byTabIndex = (byte) (this.byTabIndex == 3 ? 1 : this.byTabIndex + 1);
                                if (this.byTaskState[this.byTabIndex - 1] == 0) {
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    GameBean.BY_TYPE = (byte) (this.byTabIndex - 1);
                                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
                                } else {
                                    this.byPageIndex = 1;
                                    if (this.sTaskList[this.byTabIndex - 1] != null) {
                                        this.byTotalNum = (byte) (this.sTaskList[this.byTabIndex - 1].length / 8);
                                        this.byMaxPage = (byte) Tools.ceil(this.byTotalNum, this.byNumPerPage);
                                    } else {
                                        this.byTotalNum = 0;
                                        this.byMaxPage = 1;
                                    }
                                    this.iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 3;
                                    this.bySelectIndex = 1;
                                    this.sArray[8] = this.byTabIndex == 3 ? "去接任务" : "放弃任务";
                                }
                            } else if (this.byPageIndex < this.byMaxPage) {
                                this.byPageIndex = (byte) (this.byPageIndex + 1);
                                this.iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 10 + Constant.FONT_SMALL_HEIGHT + 2;
                                this.bySelectIndex = 2;
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_1, false)) {
                            taskQuickSelect((byte) 1);
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_2, false)) {
                            taskQuickSelect((byte) 2);
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_3, false)) {
                            taskQuickSelect((byte) 3);
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {

                            if (this.bySelectIndex > 1 && this.bySelectIndex < this.byNumPerPage + 2 && this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 0) != null) {
                                if (GameBean.BY_PRE_GAME_UI_STATE == -1) {
                                    //弹出二级操作层
                                    //发送操作
                                    if (this.byTabIndex != 3) {
                                        this.sOpArray = new String[]{"1任务寻路", "2任务传送", "3查看详情", "4放弃任务"};
                                    } else {
                                        if (this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 0).charAt(0) == '1' && this.bySingleTaskState == 0) {
                                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您等级不够，还不能去接这个任务!");
                                            return;
                                        }
                                        this.sOpArray = new String[]{"1任务寻路", "2任务传送"};
                                    }
                                    this.byUiState = 1;
                                    this.bySubSelectIndex = 1;
                                    //#if NOKIA_S60V5
                                     this.iSubPositionY = Constant.UI_START_Y + ((Constant.END_LINE - this.sOpArray.length * 37 - 7) >> 1) + 7;
                                    //#else
//#                                    this.iSubPositionY = Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.sOpArray.length * 30 - 7) >> 1) + 7;
                                    //#endif
                                } else {
                                    //插入任务
                                    this.insertTask();
                                }
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                            if (this.bySelectIndex > 1 && this.bySelectIndex < this.byNumPerPage + 2 && this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 0) != null) {
                                if (GameBean.BY_PRE_GAME_UI_STATE == -1) {
                                    //发送操作
                                    if (this.byTabIndex != 3) {
                                        this.byUiState = 2;//放弃任务
                                    } else {
                                        //立即去接任务//寻路
                                        if (this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 0).charAt(0) == '1' && this.bySingleTaskState == 0) {
                                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您等级不够，还不能去接这个任务!");
                                            return;
                                        }
                                        MainLogic.getInstance().gamePlayer.stopAutoRun(false, true);
                                        MainLogic.getInstance().clearLockedObj(0, true);
                                        MainLogic.getInstance().gamePlayer.runPathFinderForMission(this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 4), Integer.parseInt(this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 5)), Integer.parseInt(this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 6)));
                                        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                                    }
                                } else {
                                    //插入任务
                                    this.insertTask();
                                }
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            if (GameBean.BY_PRE_GAME_UI_STATE == -1) {
                                Tools.openRoamMenu(false, (byte) 1, (byte) 0, 4);
                            } else {
                                //插入任务
                                switch (GameBean.BY_PRE_GAME_UI_STATE) {
                                    case Constant.GAME_UI_CHAT:
                                        //插入任务
                                        MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, true);
                                        //MainGame.changeCanvas(InputInterFace.inputInterTask);
                                        MainGame.changeCanvas(MainLogic.getInstance().inputInterFace.inputInterTask);
                                        GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT;
//                                    GameBean.BY_PRE_GAME_UI_STATE = -1;
                                        break;
                                }
                            }
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            this.iPositionY = Tools.updateLinePos(iArray, this.iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bUiKeyPressLock = false;
                            }
                        }
                    }

                    break;
                case 1:
                    bFlag = bFlag ? false : true;
                    if (!bUiKeyPressLock) {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_1, false)) {
                            if (this.bySubSelectIndex != 1) {
                                this.bySubSelectIndex = 1;
                                this.bUiKeyPressLock = true;
                                this.byState = 1;
                                this.iArray = new int[]{1, 1, Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - sOpArray.length * 30 - 7) >> 1) + 7, 2, 50, 5};
                            }
                        } else if (this.sOpArray.length > 1 && MainCanvas.keyPressedLogic(Constant.GAME_KEY_2, false)) {
                            if (this.bySubSelectIndex != 2) {
                                this.bUiKeyPressLock = true;
                                if (bySubSelectIndex > 2) {
                                    this.byState = 2;
                                    this.iArray = new int[]{1, 1, Constant.UI_START_Y + 30 + ((Constant.DRAW_HEIGHT - sOpArray.length * 30 - 7) >> 1) + 7, 2, 50, 5};
                                } else {
                                    this.byState = 1;
                                    this.iArray = new int[]{2, 1, Constant.UI_START_Y + 30 + ((Constant.DRAW_HEIGHT - sOpArray.length * 30 - 7) >> 1) + 7, 2, 50, 5};
                                }
                                this.bySubSelectIndex = 2;
                            }
                        } else if (this.sOpArray.length > 2 && MainCanvas.keyPressedLogic(Constant.GAME_KEY_3, false)) {
                            if (this.bySubSelectIndex != 3) {
                                this.bUiKeyPressLock = true;
                                if (bySubSelectIndex > 3) {
                                    this.byState = 2;
                                    this.iArray = new int[]{1, 1, Constant.UI_START_Y + 60 + ((Constant.DRAW_HEIGHT - sOpArray.length * 30 - 7) >> 1) + 7, 2, 50, 5};
                                } else {
                                    this.byState = 1;
                                    this.iArray = new int[]{2, 1, Constant.UI_START_Y + 60 + ((Constant.DRAW_HEIGHT - sOpArray.length * 30 - 7) >> 1) + 7, 2, 50, 5};
                                }
                                this.bySubSelectIndex = 3;
                            }
                        } else if (this.sOpArray.length > 3 && MainCanvas.keyPressedLogic(Constant.GAME_KEY_4, false)) {
                            if (this.bySubSelectIndex != 4) {
                                this.bySubSelectIndex = 4;
                                this.byState = 1;
                                this.bUiKeyPressLock = true;
                                this.iArray = new int[]{2, 1, Constant.UI_START_Y + 90 + ((Constant.DRAW_HEIGHT - sOpArray.length * 30 - 7) >> 1) + 7, 2, 50, 5};
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                            if (this.bySubSelectIndex > 1) {
                                this.bySubSelectIndex = (byte) (this.bySubSelectIndex - 1);
                                this.byState = 1;
                                this.bUiKeyPressLock = true;
                                //#if NOKIA_S60V5
                                 this.iArray = new int[]{2, 1, Constant.UI_START_Y + (this.bySubSelectIndex - 1) * 37 + ((Constant.END_LINE - sOpArray.length * 37 - 7) >> 1) + 7, 2, 50, 5};
                                //#else
//#                                this.iArray = new int[]{2, 1, Constant.UI_START_Y + (this.bySubSelectIndex - 1) * 30 + ((Constant.DRAW_HEIGHT - sOpArray.length * 30 - 7) >> 1) + 7, 2, 50, 5};
                                //#endif
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                            if (this.bySubSelectIndex < this.sOpArray.length) {
                                this.bySubSelectIndex = (byte) (this.bySubSelectIndex + 1);
                                this.byState = 1;
                                this.bUiKeyPressLock = true;
                                //#if NOKIA_S60V5
                                 this.iArray = new int[]{1, 1, Constant.UI_START_Y + (this.bySubSelectIndex - 1) * 37 + ((Constant.END_LINE - sOpArray.length * 37 - 7) >> 1) + 7, 2, 50, 5};
                                //#else
//#                                this.iArray = new int[]{1, 1, Constant.UI_START_Y + (this.bySubSelectIndex - 1) * 30 + ((Constant.DRAW_HEIGHT - sOpArray.length * 30 - 7) >> 1) + 7, 2, 50, 5};
                                //#endif
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                            this.bShowMenu = false;
                            GameBean.STR_CMD_QUEST_KEY = this.sTaskList[this.byTabIndex - 1][((this.byPageIndex - 1) * 9 + this.bySelectIndex - 2) * 4];
                            switch (this.bySubSelectIndex) {
                                case 1:
                                    //任务寻路
                                    MainLogic.getInstance().gamePlayer.stopAutoRun(false, true);
                                    MainLogic.getInstance().clearLockedObj(0, true);
                                    MainLogic.getInstance().gamePlayer.runPathFinderForMission(this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 4), Integer.parseInt(this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 5)), Integer.parseInt(this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 6)));
                                    MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                                    break;
                                case 2:
                                    //任务传送
                                    this.send(this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 4), Integer.parseInt(this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 5)), Integer.parseInt(this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 6)));
                                    break;
                                case 3:
                                    //被选中的任务的索引
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    this.byUiState = 0;
                                    // 发送查询任务
                                    this.sTaskKey = this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 0);
                                    GameBean.STR_CMD_QUEST_KEY = this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 0);
                                    GameBean.L_PLAYER_ID = MainLogic.getInstance().gamePlayer.lPlayerID;
                                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_INFO, Constant.SOCKET_MSG_TYPE_LOGIC);
                                    break;
                                case 4:
                                    //放弃任务
                                    this.byUiState = 2;
                                    break;

                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            this.byUiState = 0;
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            this.iSubPositionY = Tools.updateLinePos(iArray, this.iSubPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bUiKeyPressLock = false;
                            }
                        }
                    }
                    break;
                case 2:
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                        //放弃任务
                        GameBean.STR_CMD_QUEST_KEY = this.getTaskListArrayIndex((byte) (this.bySelectIndex - 2), (byte) 0);
                        if (this.sPreTaskKey != null && this.sPreTaskKey.equals(GameBean.STR_CMD_QUEST_KEY)) {
                            this.bDelPreTaskKey = true;
                        }
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_DELETE_QUEST, Constant.SOCKET_MSG_TYPE_LOGIC);
                        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                    } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                        this.byUiState = 0;
                    }
                    break;
            }
        }
    }

    /**
     * 绘制任务列表界面
     * @param g 
     */
    public void drawTaskList(Graphics g) {
        //#if NOKIA_S60V5
         if (this.byTabIndex != 3) {
             //放弃任务
             Tools.drawS60V5Frame(g, this.imgArray[5], this.imgArray[8], this.imgArray[9], this.imgArray[10], this.imgArray[4], 52, 2, 43, 22, this.imgArray[4], 196, 52, 96, 24, this.sArray[0]);
         } else {
             //去接任务
             Tools.drawS60V5Frame(g, this.imgArray[5], this.imgArray[8], this.imgArray[9], this.imgArray[10], this.imgArray[4], 52, 2, 43, 22, this.imgArray[4], 100, 80, 96, 24, this.sArray[0]);
         }
 //        g.drawRegion(this.imgArray[4], 96, 0, 48, 24, Constant.TRANS_NONE, Constant.UI_START_X + 12, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 38, Graphics.TOP | Graphics.LEFT);
         //绘制翻页
         Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[6], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 33);
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[5],  this.sArray[8],this.sArray[7], this.sArray[0]);
//#         Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[6], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + Constant.DRAW_HEIGHT - Constant.FONT_SMALL_HEIGHT - 3 + (Constant.FONT_SMALL_HEIGHT - 9 >> 1));
        //#else
//#        Tools.drawFrame(g, this.imgArray[5], this.imgArray[1], this.sArray[8], this.sArray[7], this.sArray[0]);
//#        Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[6], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + Constant.DRAW_HEIGHT - Constant.FONT_SMALL_HEIGHT - 3 + (Constant.FONT_SMALL_HEIGHT - 9 >> 1));
        //#endif

        //绘制表头
        Tools.drawOpWord(g, this.sArray[1], this.byTabIndex == 1 ? true : false, (byte) 1, this.imgArray[0], Constant.UI_START_X + 12, this.iStartPointY, 0xFFFFFF, 0x00ccff, 0x000000);
        Tools.drawOpWord(g, this.sArray[2], this.byTabIndex == 2 ? true : false, (byte) 1, this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[2])) >> 1), this.iStartPointY, 0xFFFFFF, 0x00ccff, 0x000000);
        Tools.drawOpWord(g, this.sArray[3], this.byTabIndex == 3 ? true : false, (byte) 1, this.imgArray[0], Constant.UI_START_X + Constant.DRAW_WIDTH - 12 - Constant.FONT_SMALL.stringWidth(this.sArray[3]), this.iStartPointY, 0xFFFFFF, 0x00ccff, 0x000000);
        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 5, Constant.DRAW_WIDTH);
        //绘制任务列表
        if (this.sTaskList[this.byTabIndex - 1] != null) {
            int startIndex = (this.byPageIndex - 1) * this.byNumPerPage;
            int endIndex = this.byPageIndex * this.byNumPerPage > this.byTotalNum ? this.byTotalNum : this.byPageIndex * this.byNumPerPage;
            this.iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 10;
            boolean add = false;
            if (staskList == null) {
            	staskList = new int[endIndex-startIndex][];
            	add = true;
            }
            for (int i = startIndex; i < endIndex; i++) {
            	int prestarty = iStartY;
            	iStartY = this.drawTaskListItem(g, i, this.bySelectIndex > 1 && (this.bySelectIndex - 2 + (this.byPageIndex - 1) * this.byNumPerPage == i) ? true : false, Constant.UI_START_X + 40, iStartY);
            	if (add)
            		staskList[i-startIndex] = new int[]{0,prestarty,360,iStartY-prestarty};
            }
        }
        if (this.byUiState == 0 && this.bySelectIndex > 1) {
            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iPositionY, Constant.DRAW_WIDTH);
        }
        //#if NOKIA_S60V5
         if (this.byUiState == 1) {
             //绘制背景遮罩层
             Tools.drawTilePic(g, (byte) 2, Constant.UI_START_X, Constant.UI_START_Y, 640, this.imgArray[3], 0, 0, Constant.DRAW_WIDTH, 10, Constant.TRANS_NONE);
             //绘制弹出操作层
             Tools.drawPopOperation(g, this.imgArray[2], 0x9c9c9c, 0x666666, this.sOpArray, 120, 30, 7, 0xFFFFFF, 0x0099FF, this.bySubSelectIndex, 0, 0);
//             Tools.drawGapSlectMask(g, this.imgArray[1], this.imgArray[0], bFlag, 30, Constant.UI_START_X, iSubPositionY, Constant.DRAW_WIDTH);
             if (tastoperate == null) {
            	 tastoperate = Tools.getPopOperationRect(this.imgArray[2], 0x9c9c9c, 0x666666, this.sOpArray, 120, 30, 7, 0xFFFFFF, 0x0099FF, this.bySubSelectIndex, 0, 0);
             }
             MainView.drawTouchRect(g, tastoperate);
         } else if (this.byUiState == 2) {
             Tools.drawPopUp(g, (byte) 4, Constant.UI_START_X + 15, Constant.UI_START_Y + ((Constant.END_LINE - 120) >> 1), 310, 120, this.imgArray[2], 0x9c9c9c, imgArray[7], 22, 0, 21, 10, imgArray[7], 0, 0, 22, 10, this.sArray[5], this.sArray[6]);
         }
        //#else
//#        if (this.byUiState == 1) {
//#            //绘制背景遮罩层
//#            Tools.drawTilePic(g, (byte) 2, Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_HEIGHT, this.imgArray[3], 0, 0, Constant.DRAW_WIDTH, 10, Constant.TRANS_NONE);
//#            //绘制弹出操作层
//#            Tools.drawPopOperation(g, this.imgArray[2], 0x989898, 0x666666, this.sOpArray, 90, 23, 7, 0xFFFFFF, 0x0099FF, this.bySubSelectIndex, 0, 0);
//#            Tools.drawGapSlectMask(g, this.imgArray[1], this.imgArray[0], bFlag, 23, Constant.UI_START_X, iSubPositionY, Constant.DRAW_WIDTH);
//#        } else if (this.byUiState == 2) {
//#            Tools.drawPopUp(g, (byte) 4, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 80) >> 1), 232, 80, this.imgArray[2], 0x989898, imgArray[7], 0, 0, 22, 10, imgArray[7], 22, 0, 21, 10, this.sArray[5], this.sArray[6]);
//#        }
        //#endif
      
         
    }
    private static int[][] staskList,tastoperate;
    public void checkTouchTaskList(int x, int y) {
    	switch(byUiState) {
    	case 0:
    		int[][] tabletouch = new int[][]{
    				{0,46,104,35},
    				{110,46,140,35},
    				{250,46,110,35},
    		};
    		int touched = MainCanvas.checkTouch(x, y, tabletouch);
    		if (touched >= 0) {
    		switch(byTabIndex) {
    		case 1:
    			if (touched == 1){
    				bySelectIndex = 1;
        			MainCanvas.pressDir(3);
        			staskList = null;
        		} else if (touched == 2) {
        			bySelectIndex = 1;
        			MainCanvas.pressDir(2);
        			staskList = null;
        		} else {
        			if (bySelectIndex > 1) {
        				bySelectIndex = 2;
        				MainCanvas.pressDir(0);
        				staskList = null;
        			}
        		}
    			break;
    		case 2:
    			if (touched == 0){
    				bySelectIndex = 1;
        			MainCanvas.pressDir(2);
        			staskList = null;
        		} else if (touched == 2) {
        			bySelectIndex = 1;
        			MainCanvas.pressDir(3);
        			staskList = null;
        		} else {
        			if (bySelectIndex > 1) {
        				bySelectIndex = 2;
        				MainCanvas.pressDir(0);
        				staskList = null;
        			}
        		}
    			break;
    		case 3:
    			if (touched == 0){
    				bySelectIndex = 1;
        			MainCanvas.pressDir(3);
        			staskList = null;
        		} else if (touched == 1) {
        			bySelectIndex = 1;
        			MainCanvas.pressDir(2);
        			staskList = null;
        		} else {
        			if (bySelectIndex > 1) {
        				bySelectIndex = 2;
        				MainCanvas.pressDir(0);
        				staskList = null;
        			}
        		}
    			break;
    		}
    		}
    		
            //绘制任务列表
    		if (staskList != null && staskList.length > 0) {
    			touched = MainCanvas.checkTouch(x, y, staskList);
    			if (touched >= 0) {
    				bySelectIndex = (byte) (touched+2);
    				MainCanvas.pressFire();
    			}
    		}
    		MainCanvas.checkSoftKey();
    		break;
    	case 1:
    		tastoperate = Tools.getPopOperationRect(this.imgArray[2],
					0x9c9c9c, 0x666666, this.sOpArray, 120, 30, 7, 0xFFFFFF,
					0x0099FF, this.bySubSelectIndex, 0, 0);
//    			new int[][]{
//    				{92,132,178,33},
//    				{92,170,178,33},
//    				{92,208,178,33},
//    				{92,244,178,33},
//    		};
    		touched = MainCanvas.checkTouch(x, y, tastoperate);
    		if (touched >= 0) {
    			if (touched + 1 == bySubSelectIndex) {
    				MainCanvas.pressFire();
    			} else {
    				MainCanvas.pressNum(touched+1);
    			}
    		} else {
    			MainCanvas.pressBack();
    		}
    		break;
    	case 2:
    		MainCanvas.checkSoftKey();
    		break;
    	}
    }

    /**
     * 清除任务列表界面资源
     */
    public void clearTaskList() {
        this.imgArray = null;
        this.sItems = null;
        this.sArray = null;
        this.sTaskList = null;
        this.byTaskState = null;
        GameBean.BY_PRE_GAME_UI_STATE = -1;
        this.bySingleTaskState = -1;
        //#if NOKIA_E72
//#         Tools.clearE72ScollBar();
        //#endif
    }

    /**
     * 绘制任务标题
     * @param g
     * @param item 任务标题
     * @param state 任务状态
     * @param startX
     * @param startY
     */
    private int drawTaskListItem(Graphics g, int index, boolean bSelected, int startX, int startY) {
        //绘制类型，绘制等级，绘制任务名称名称
        if (this.sTaskList[this.byTabIndex - 1][index * 8] == null) {
            return startY + Constant.FONT_SMALL_HEIGHT + 2;
        }
        byte code = -1;
        if (this.byTabIndex == 1) {
            code = Byte.parseByte(this.sTaskList[this.byTabIndex - 1][index * 8 + 7]);
        }
        char num = this.sTaskList[this.byTabIndex - 1][index * 8].charAt(0);
        switch (num) {
            case '1':
                if (this.byTabIndex != 3) {
                    Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[0], startX, startY, 0xFF9900, 0x000000);
                    startX = startX + Constant.FONT_SMALL.stringWidth(this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[0]);
                    Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 1], startX, startY, (code == 2 ? 0xFF0000 : 0xFFFFFF), 0x000000);
                } else {
                    switch (this.bySingleTaskState) {
                        case 0:
                            Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[0], startX, startY, 0xFF9900, 0x000000);
                            startX = startX + Constant.FONT_SMALL.stringWidth(this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[0]);
                            g.setColor(0x333333);
                            g.drawString(this.sTaskList[this.byTabIndex - 1][index * 8 + 1], startX, startY, 0);
                            break;
                        case 1:
                            Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[0], startX, startY, 0xFF9900, 0x000000);
                            startX = startX + Constant.FONT_SMALL.stringWidth(this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[0]);
                            Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 1], startX, startY, (code == 2 ? 0xFF0000 : 0xFFFFFF), 0x000000);
                            break;
                    }
                }
                break;
            case '2':
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[1], startX, startY, 0x0000ff, 0x000000);
                startX = startX + Constant.FONT_SMALL.stringWidth(this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[1]);
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 1], startX, startY, (code == 2 ? 0xFF0000 : 0xFFFFFF), 0x000000);
                break;
            case '3':
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[2], startX, startY, 0x0000ff, 0x000000);
                startX = startX + Constant.FONT_SMALL.stringWidth(this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[2]);
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 1], startX, startY, (code == 2 ? 0xFF0000 : 0xFFFFFF), 0x000000);
                break;
            case '4':
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[3], startX, startY, 0x0000ff, 0x000000);
                startX = startX + Constant.FONT_SMALL.stringWidth(this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[3]);
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 1], startX, startY, (code == 2 ? 0xFF0000 : 0xFFFFFF), 0x000000);
                break;
            case '5':
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[4], startX, startY, 0x660099, 0x000000);
                startX = startX + Constant.FONT_SMALL.stringWidth(this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[4]);
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 1], startX, startY, (code == 2 ? 0xFF0000 : 0xFFFFFF), 0x000000);
                break;
            case '6':
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[5], startX, startY, 0xea0c26, 0x000000);
                startX = startX + Constant.FONT_SMALL.stringWidth(this.sTaskList[this.byTabIndex - 1][index * 8 + 2] + this.sTaskPreArray[5]);
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 1], startX, startY, (code == 2 ? 0xFF0000 : 0xFFFFFF), 0x000000);
                break;
            default:
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 2], startX, startY, 0x0099ff, 0x000000);
                startX = startX + Constant.FONT_SMALL.stringWidth(this.sTaskList[this.byTabIndex - 1][index * 8 + 2]);
                Tools.drawShadowString(g, (byte) 1, this.sTaskList[this.byTabIndex - 1][index * 8 + 1], startX, startY, (code == 2 ? 0xFF0000 : 0xFFFFFF), 0x000000);
                break;
        }
        if (bSelected) {
            if (this.sTaskList[this.byTabIndex - 1][index * 8 + 3] != null) {
                int height = Tools.getParagraphHeight(this.sTaskList[this.byTabIndex - 1][index * 8 + 3], Constant.DRAW_WIDTH - 24, Constant.FONT_SMALL_HEIGHT + 1) + 4;
                Tools.drawTilePic(g, (byte) 2, Constant.UI_START_X, startY + Constant.FONT_SMALL_HEIGHT + 1, height, this.imgArray[3], 0, 0, Constant.DRAW_WIDTH, 20, Constant.TRANS_NONE);
                if (code == 2) {
                    Tools.drawParagraph(g, Constant.UI_START_X + 12, startY + Constant.FONT_SMALL_HEIGHT + 2, Constant.DRAW_WIDTH - 24, this.sArray[9], 0xff0000, Constant.FONT_SMALL_HEIGHT + 1, -1);
                } else {
                    Tools.drawParagraph(g, Constant.UI_START_X + 12, startY + Constant.FONT_SMALL_HEIGHT + 2, Constant.DRAW_WIDTH - 24, this.sTaskList[this.byTabIndex - 1][index * 8 + 3], 0x4bb5cb, Constant.FONT_SMALL_HEIGHT + 1, -1);
                }
                return startY + height + Constant.FONT_SMALL_HEIGHT;
            }
        }
        return startY + Constant.FONT_SMALL_HEIGHT + 2;
    }

    //返回指定额任务列表数组胡总的指定索引的值
    public String getTaskListArrayIndex(byte bySelectIndex, byte byArrayIndex) {
        return this.sTaskList[this.byTabIndex - 1][((this.byPageIndex - 1) * this.byNumPerPage + bySelectIndex) * 8 + byArrayIndex];
    }
    /************************打开传送列表**************************************************************/
    private String[] sTransferList;

    public void setTransferList(String[] sTransferList) {
        if (sTransferList == null) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "没有找到任何的传送点!!");
            return;
        }
//        for (int i = 0; i < sTransferList.length; i++) {
//            System.out.println(i + "    " + sTransferList[i]);
//        }
        this.sTransferList = sTransferList;
        MainLogic.getInstance().pushState(Constant.GAME_UI_TRANSFER_LIST, true);
    }

    /**
     * 初始化传送列资源
     */
    public void initTransferList() {
        this.bUiKeyPressLock = false;
        this.sArray = new String[]{"传送列表", "级", "确定", "返回"};
        this.bySelectIndex = 1;
        this.byPageIndex = 1;
//        sTransferList = new String[]{"12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111", "12222", "悬雍垂", "22", "122", "111"};
        //#if NOKIA_S60V5
         this.byNumPerPage = 12;
        //#elif NOKIA_E72
//#         this.byNumPerPage = 6;
        //#else
//#        this.byNumPerPage = 8;
        //#endif
        this.byTotalNum = 0;
        if (sTransferList != null) {
            this.byTotalNum = (byte) (sTransferList.length / 5);
            this.byMaxPage = (byte) Tools.ceil(this.byTotalNum, this.byNumPerPage);
        } else {
            this.byMaxPage = 1;
        }
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 60;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 28;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 30;
        //#endif
        this.iPositionY = this.iStartPointY - ((23 - Constant.FONT_SMALL_HEIGHT) >> 1);
        try {
            //弹出层的UI
            //#if NOKIA_S60V5
             this.imgArray = new Image[8];
             this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();            //蓝色的线
             this.imgArray[2] = ResManager.createImage(90000043);            //确定，返回文字图片
             this.imgArray[3] = ResManager.createImage(90000017);            //背景图片
             this.imgArray[4] = ResManager.createImage(90000047);            //大数字图片
             this.imgArray[5] = ResManager.createImage(90000084);            //方向将
             this.imgArray[6] = ResManager.createImage(90000085);            //确认
             this.imgArray[7] = ResManager.createImage(90000086);            //蓝条
            //#else
//#            this.imgArray = new Image[5];
//#            this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();            //蓝色的线
//#//            this.imgArray[2] = ResManager.createImage(90000043);            //确定，返回文字图片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[3] = ResManager.createImage(90000017);
//# //            imgArray[3] = Tools.ZoomImage(imgArray[3], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[3] = ResManager.createImage(90000017);            //背景图片        
            //#endif
//#            this.imgArray[4] = ResManager.createImage(90000047);            //大数字图片
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
            Tools.printLog("初始化任务列表界面出错");
        }
        
        //Yujiang
        setTransferListTouchRect();
    }

    /**
     * 更新传送列表
     */
    public void updateTransferList() {
        if (!bUiKeyPressLock) {
            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                if (bySelectIndex > 1) {
                    this.byState = 1;
                    this.bySelectIndex -= 1;
                    this.bUiKeyPressLock = true;
                    this.iArray = new int[]{2, 1, this.iStartPointY + (bySelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT + 4) - ((23 - Constant.FONT_SMALL_HEIGHT) >> 1), 2, 150, 5};
                }
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                if (this.bySelectIndex < this.byNumPerPage && this.bySelectIndex + (this.byPageIndex - 1) * this.byNumPerPage < this.byTotalNum) {
                    this.byState = 2;
                    this.bUiKeyPressLock = true;
                    this.bySelectIndex += 1;
                    this.iArray = new int[]{1, 1, this.iStartPointY + (bySelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT + 4) - ((23 - Constant.FONT_SMALL_HEIGHT) >> 1), 2, 150, 5};
                }
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                if (this.byPageIndex > 1) {
                    this.byState = 1;
                    this.bUiKeyPressLock = true;
                    this.byPageIndex = (byte) (this.byPageIndex - 1);
                    this.bySelectIndex = 1;
                    this.iArray = new int[]{2, 1, this.iStartPointY + (bySelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT + 4) - ((23 - Constant.FONT_SMALL_HEIGHT) >> 1), 2, 150, 5};
                }
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                if (this.byMaxPage > 1 && this.byPageIndex < this.byMaxPage) {
                    this.byState = 2;
                    this.bUiKeyPressLock = true;
                    this.byPageIndex = (byte) (this.byPageIndex + 1);
                    this.bySelectIndex = 1;
                    this.iArray = new int[]{2, 1, this.iStartPointY + (bySelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT + 4) - ((23 - Constant.FONT_SMALL_HEIGHT) >> 1), 2, 150, 5};
                }
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                if (this.bySelectIndex >= 1 && this.bySelectIndex <= this.byNumPerPage) {
                    //发送传送的指令
                    if (MainLogic.getInstance().gamePlayer.iPlayerLevel < Integer.parseInt(this.sTransferList[((this.byPageIndex - 1) * this.byNumPerPage + (this.bySelectIndex - 1)) * 5 + 2])) {
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的等级不够，不可以传送!");
                        return;
                    } else if (MainLogic.getInstance().uiInterFace.sRoamMapKeys.equals(this.sTransferList[((this.byPageIndex - 1) * this.byNumPerPage + (this.bySelectIndex - 1)) * 5])) {
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您已经在该场景了不用传送了!");
                        return;
                    }
                    this.bUiKeyPressLock = true;
                    this.send(this.sTransferList[((this.byPageIndex - 1) * this.byNumPerPage + (this.bySelectIndex - 1)) * 5], Integer.parseInt(this.sTransferList[((this.byPageIndex - 1) * this.byNumPerPage + (this.bySelectIndex - 1)) * 5 + 3]), Integer.parseInt(this.sTransferList[((this.byPageIndex - 1) * this.byNumPerPage + (this.bySelectIndex - 1)) * 5 + 4]));
                }
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
            }
        } else {
            if (this.byState == 1 || this.byState == 2) {
                this.iPositionY = Tools.updateLinePos(iArray, this.iPositionY);
                if (this.iArray == null || this.iArray[1] == 0) {
                    this.byState = 0;
                    this.bUiKeyPressLock = false;
                }
            }
        }
        MainCanvas.clearInput();
    }

    /**
     * 绘制传送列表
     * @param g 
     */
    public void drawTransferList(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[3], this.imgArray[5], this.imgArray[6], this.imgArray[7], this.imgArray[2], this.sArray[0]);
         //绘制翻页
         Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[4], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 33);
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[3], this.sArray[2], this.sArray[3], this.sArray[0]);
//#         //绘制翻页
//#         Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[4], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 2 - Constant.FONT_SMALL_HEIGHT + (Constant.FONT_SMALL_HEIGHT - 9 >> 1));
        //#else
//#        Tools.drawFrame(g, this.imgArray[3], this.imgArray[1], this.sArray[2], this.sArray[3], this.sArray[0]);
//#        //绘制翻页
//#        Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[4], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 3 - Constant.FONT_SMALL_HEIGHT + (Constant.FONT_SMALL_HEIGHT - 9 >> 1));
        //#endif
        if (this.byTotalNum > 0) {
            short startIndex = (short) ((this.byPageIndex - 1) * this.byNumPerPage);
            short endIndex = (short) (this.byPageIndex * this.byNumPerPage > this.byTotalNum ? this.byTotalNum : this.byPageIndex * this.byNumPerPage);
            for (short i = startIndex; i < endIndex; i++) {
                //绘制传送目标点名称
                if (this.bySelectIndex != this.byNumPerPage + 1 && this.bySelectIndex - 1 == i - (this.byPageIndex - 1) * this.byNumPerPage) {
                    Tools.setColor(g, Constant.SELECTED_COLOR);
                } else {
                    Tools.setColor(g, 0xffffff);
                }
                g.drawString(sTransferList[i * 5 + 1], Constant.UI_START_X + 23, this.iStartPointY + (i - (this.byPageIndex - 1) * this.byNumPerPage) * (Constant.FONT_SMALL_HEIGHT + 4), g.LEFT | g.TOP);
                g.drawString(sTransferList[i * 5 + 2] + this.sArray[1], Constant.UI_START_X + Constant.DRAW_WIDTH - 23, this.iStartPointY + 2 + (i - (this.byPageIndex - 1) * this.byNumPerPage) * (Constant.FONT_SMALL_HEIGHT + 4), g.RIGHT | g.TOP);
                //绘制等级限制
            }
            if (this.bySelectIndex != this.byNumPerPage + 1) {
                Tools.drawGapSlectMask(g, this.imgArray[1], this.imgArray[0], this.bFlag, 22, Constant.UI_START_X, this.iPositionY, Constant.DRAW_WIDTH);
            } else {
//                Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iPositionY, Constant.DRAW_WIDTH);
            }
        }
        
	    	
	 	   //Yujiang
	     if(mTransferListTouchRect != null)
	    	 MainView.drawTouchRect(g, mTransferListTouchRect);
	     MainView.drawTouchRect(g, mTransferListPageTouchRect);
    }

    public void clearTransferList() {
        this.imgArray = null;
        this.sTransferList = null;
        this.sArray = null;
        this.bySingleTaskState = -1;
    }

    /****************************分隔线*************************接受/归还任务*********************************************************************************/
    /**
     * 显示接受或是查询,完成任务界面 
     * @param byTaskUiState (1，接受，2查询,3完成任务)
     * @param lNPCID //npcID
     * @param sTaskName 任务名称
     * @param sTaskDesc 任务描述
     * @param sTaskTarget 任务目标
     * @param lTaskAwardMoney 任务奖励金钱
     * @param iTaskAwardExp 任务奖励经验
     * @param iTaskAwardPower 任务奖励修为
     * @param byTaskItemChoiceStyle  任务物品奖励方式()
     * @param shSendstoneNum    //背包中传送石头的个数
     * @param byItemJobLimit //奖励物品是否需要选择和自己职业相同的
     * @param byItemJobLimit //任务的类型();
     */
    public void setTask(byte byTaskUiState, long lNPCID, String sTaskName, String sTaskDesc, long lTaskAwardMoney, int iTaskAwardExp, int iTaskAwardPower, byte byTaskItemChoiceStyle, short shSendstoneNum, byte bySingleTaskState, short shTaskLevel, byte byItemJobLimit, byte byCurrentTaskType) {
        this.lNPCID = lNPCID;
        this.sTaskKey = GameBean.STR_CMD_QUEST_KEY;
//        this.sTaskKey = "11111";
        this.byTaskUiState = byTaskUiState;
        this.sTaskName = sTaskName;
        this.sTaskDesc = sTaskDesc;
        this.byTaskItemChoiceStyle = byTaskItemChoiceStyle;
        this.lMoney = lTaskAwardMoney;
        this.iTaskAwardExp = iTaskAwardExp;
        this.iTaskAwardPower = iTaskAwardPower;
        this.sSenceKey = sSenceKey;
        this.iTaskCoordinate = iTaskCoordinate;
        this.shSendstoneNum = shSendstoneNum;
        this.bySingleTaskState = bySingleTaskState;
        this.shTaskLevel = shTaskLevel;
        this.sTaskName = this.getTaskNamePre(sTaskKey, (byte) 2) + "-" + this.sTaskName + "-" + String.valueOf(this.shTaskLevel) + "级";
        this.byItemJobLimit = byItemJobLimit;
        this.byCurrentTaskType = byCurrentTaskType;
        if (this.byTaskUiState == 2) {
            switch (this.bySingleTaskState) {
                case 0:
                    this.sTaskName += "(未接)";
                    break;
                case 1:
                    this.sTaskName += "(已接)";
                    break;
                case 2:
                    this.sTaskName += "(失败)";
                    break;
                case 3:
                    this.sTaskName += "(完成)";
                    break;
            }
        }

        MainLogic.getInstance().pushState(Constant.GAME_UI_ACCEPT_TASK, true);
    }

    /**
     * 任务已经接受，已经完成
     */
    public void setTask(long lNPCID, String sTaskName, String sTaskDesc, long lTaskAwardMoney, int iTaskAwardExp, int iTaskAwardPower, byte byTaskItemChoiceStyle, short shTaskLevel, byte byItemJobLimit) {
        this.setTask((byte) 3, lNPCID, sTaskName, sTaskDesc, lTaskAwardMoney, iTaskAwardExp, iTaskAwardPower, byTaskItemChoiceStyle, (short) 0, (byte) 2, shTaskLevel, byItemJobLimit, (byte) -1);
    }

    /**
     * 接受任务
     */
    public boolean acceptTask() {
        GameBean.SH_CMD_QUEST = 2;
        GameBean.L_NPC_ID = this.lNPCID;
        GameBean.STR_CMD_QUEST_KEY = this.sTaskKey;
        this.byPreTaskType = this.byCurrentTaskType;
        this.sPreTaskKey = this.sTaskKey;
//        System.out.println(" GameBean.STR_CMD_QUEST_KEY  :::  " + GameBean.STR_CMD_QUEST_KEY);
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST, Constant.SOCKET_MSG_TYPE_LOGIC);

        if (GameBean.STR_CMD_QUEST_KEY.equals("1002")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 2, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 2;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导2");
            return true;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1008")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 8, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 8;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导8");
            return true;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1007")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 7, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 7;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导7");
            return true;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1009")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 9, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 9;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导9");
            return true;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1010")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 11, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 11;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导11");
            return true;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1011")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 12, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 12;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导12");
            return true;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1015")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 15, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 15;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导15");
            return true;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1022")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 18, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 18;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
            MainLogic.getInstance().uiInterFace.sysMessage.getNpcID = GameBean.L_NPC_ID;
//            System.out.println("引导18");
            return true;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1028")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 20, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 20;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导20");
            return true;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1040")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 27, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 27;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
            MainLogic.getInstance().uiInterFace.sysMessage.getNpcID = GameBean.L_NPC_ID;
//            System.out.println("引导27");
            return true;
        } //
        else {
            return true;
        }
    }

    /**
     * 完成任务提交
     */
    public void finishTask() {
        if (this.items != null) {
            GameBean.BY_GOODS_NUM = (byte) this.items.getMaxColumNum();
        } else {
            GameBean.BY_GOODS_NUM = 0;
        }
        //完成任务提交
        if (GameBean.BY_GOODS_NUM > 0 && this.byTaskItemChoiceStyle == 1 && (this.byItemSelectIndex == -1 || !this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1)))) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您还没有选择奖励物品!");
            return;
        }
        GameBean.SH_CMD_QUEST = 3;
        GameBean.L_NPC_ID = this.lNPCID;
        GameBean.STR_CMD_QUEST_KEY = this.sTaskKey;
        GameBean.BY_TYPE = this.byTaskItemChoiceStyle;
        GameBean.STR_CDM_GOODS_KEY = "";
        if (GameBean.BY_GOODS_NUM > 0 && this.byTaskItemChoiceStyle == 1) {
            GameBean.BY_GOODS_NUM = 1;
            if (this.byItemJobLimit == 1 && MainLogic.getInstance().gamePlayer.iplayerOccupation != this.items.getGoodsJob((short) (this.byItemSelectIndex - 1))) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请选择与您职业相符的奖励物品!");
                return;
            }
            GameBean.STR_CDM_GOODS_KEY = this.items.getGoodsKey((short) (this.byItemSelectIndex - 1));
        } else if (this.byTaskItemChoiceStyle == 2 && GameBean.BY_GOODS_NUM > 0) {
            GameBean.STR_CDM_GOODS_KEY_ARRAY = new String[GameBean.BY_GOODS_NUM];
            byte j = 0;
            for (byte i = 0; i < 7; i++) {
                if (this.items.checkColumnHasGoods(i)) {
                    GameBean.STR_CDM_GOODS_KEY_ARRAY[j] = this.items.getGoodsKey(i);
                    j++;
                }
            }
        } else {
            GameBean.BY_GOODS_NUM = 0;
        }
        if (this.sPreTaskKey != null && this.sPreTaskKey.equals(GameBean.STR_CMD_QUEST_KEY)) {
            this.sPreTaskKey = null;
            this.byPreTaskType = -1;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1001")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 1, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 1;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导2");
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1003")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 3, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 3;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导13   " + GameBean.STR_CDM_GOODS_KEY);
            MainLogic.getInstance().uiInterFace.sysMessage.getGuideGoodKey = GameBean.STR_CDM_GOODS_KEY;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1005")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 5, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 5;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导5   " + GameBean.STR_CDM_GOODS_KEY);
            MainLogic.getInstance().uiInterFace.sysMessage.getGuideGoodKey = GameBean.STR_CDM_GOODS_KEY;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1006")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 6, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 6;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
//            System.out.println("引导13   " + GameBean.STR_CDM_GOODS_KEY);
            MainLogic.getInstance().uiInterFace.sysMessage.getGuideGoodKey = GameBean.STR_CDM_GOODS_KEY;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1008")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 8, 2);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 8;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 2;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1009")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 9, 5);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 9;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 5;
            MainLogic.getInstance().uiInterFace.sysMessage.getNpcID = GameBean.L_NPC_ID;
//            System.out.println("引导9");
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1013")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 13, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 13;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
            MainLogic.getInstance().uiInterFace.sysMessage.getNpcID = GameBean.L_NPC_ID;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1014")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 14, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 14;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1015")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 16, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 16;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1020")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 17, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 17;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1027")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 19, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 19;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1028")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 21, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 21;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
            MainLogic.getInstance().uiInterFace.sysMessage.getNpcID = GameBean.L_NPC_ID;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1029")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 22, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 22;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
            MainLogic.getInstance().uiInterFace.sysMessage.getNpcID = GameBean.L_NPC_ID;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1030")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 23, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 23;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
            MainLogic.getInstance().uiInterFace.sysMessage.getNpcID = GameBean.L_NPC_ID;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1031")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 24, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 24;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
            MainLogic.getInstance().uiInterFace.sysMessage.getNpcID = GameBean.L_NPC_ID;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1033")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 25, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 25;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
        }
        if (GameBean.STR_CMD_QUEST_KEY.equals("1039")) {
            MainLogic.getInstance().uiInterFace.sysMessage.initGuide("引导", 26, 0);
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][0] = 26;
            MainLogic.getInstance().uiInterFace.sysMessage.StateGuide[0][1] = 0;
        }
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST, Constant.SOCKET_MSG_TYPE_LOGIC);
        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);

    }

    /**
     * 放弃任务
     */
    public void giveUpTask() {
        //放弃任务
        GameBean.STR_CMD_QUEST_KEY = this.sTaskKey;
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_DELETE_QUEST, Constant.SOCKET_MSG_TYPE_LOGIC);
        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
    }

    /**
     * 初始化任务
     */
    public void initTask() {
//        setTask((byte) 1, 11111111, "天庭啊宽度", "中国航空博物馆是中国第一座对外开放的大型航空博物馆、亚洲最大的航空珍品荟萃地。座落在北京昌平大汤山脚下。筹建工作始于1986年10月，经过三年时间的采集装修，于1989年11月11日正式向社会开放。目前，共收藏飞机122个型号，共299架，导弹、雷达、高炮等武器装备600余种，见证了中国航空从无到有，从弱到强的历史变化。2007年8月20日，中国航空博物馆经全国旅游景区质量等级评定委员会评定为国家4A级旅游景区。 2010年铁血军品行更名为铁血君品行，是国内最大的军品购物商城。铁血军品行由铁血网直接运营管理，在北京、上海、成都、深圳、哈尔滨开有连锁店，主要经销美国ALPHA服装，Traser军表，德军服装，511军品，太眼镜，军靴，户外等各类军品。正品保障，假一赔十。 。",
//                3333333,
//                333,
//                4556,
//                (byte) 1,
//                (short) 0,
//                (byte) 1,
//                (short) 10,
//                (byte) 0,
//                (byte) 1);
//
//        this.items = new Goods((short) 4, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.items.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, "叶凡轮动阴阳圣剑，将紫府圣子斩死，头颅与神识成为灰烬，只刺下一具无头的尸体在喷涌鲜血", (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, "叶凡轮动阴阳圣剑，将紫府圣子斩死，头颅与神识成为灰烬，只刺下一具无头的尸体在喷涌鲜血", (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 2, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, "叶凡轮动阴阳圣剑，将紫府圣子斩死，头颅与神识成为灰烬，只刺下一具无头的尸体在喷涌鲜血", (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 3, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, "叶凡轮动阴阳圣剑，将紫府圣子斩死，头颅与神识成为灰烬，只刺下一具无头的尸体在喷涌鲜血", (short) 10, 5, (byte) 99, "10031");
        this.bUiKeyPressLock = false;
        GameBean.b_WAIT_NET_MSG_BACK = false;
        //道具的分页
        this.byPageIndex = 1;
        if (this.items != null && this.items.getMaxColumNum() > 0) {
            this.byMaxPage = (byte) (this.items.getMaxColumNum());
        } else {
            this.byMaxPage = 0;
        }
       
        this.byPopUpState = 1;
        this.byUiState = 0;
        this.sArray = new String[]{"", "提示", "您确定要放弃该任务么?", "", "返回"};

        //绘制任务奖励
        if (this.lMoney > 0 || this.iTaskAwardExp > 0 || this.iTaskAwardPower > 0 || (this.items != null && this.items.getMaxColumNum() > 0)) {
            //#if NOKIA_S60V5
             this.sArray[0] = this.items != null && this.items.getMaxColumNum() > 0 ? "<l任务奖励(点击此处查看奖励物品)：>" : "<l任务奖励：>";
            //#else
//#            this.sArray[0] = this.items != null && this.items.getMaxColumNum() > 0 ? "<l任务奖励(0键查看物品)：>" : "<l任务奖励：>";
            //#endif
        }
        //绘制金钱和修为经验奖励

        if (this.lMoney > 0) {
            this.sArray[0] += "|金钱：" + Tools.moneyConvert(this.lMoney);
        }
        if (this.iTaskAwardPower > 0) {
            //#if NOKIA_S60V5
             this.sArray[0] += "|修为：" + iTaskAwardPower;
            //#else
//#            if (this.lMoney > 0) {
//#                this.sArray[0] += "  修为：" + iTaskAwardPower;
//#            } else {
//#                this.sArray[0] += "|修为：" + iTaskAwardPower;
//#            }
            //#endif
        }
        if (this.iTaskAwardExp > 0) {
            //#if NOKIA_S60V5
             this.sArray[0] += "|经验：" + this.iTaskAwardExp;
            //#else
//#            if (this.lMoney > 0 || this.iTaskAwardPower > 0) {
//#                this.sArray[0] += " 经验：" + this.iTaskAwardExp;
//#            } else {
//#                this.sArray[0] += "|经验：" + this.iTaskAwardExp;
//#            }
            //#endif
        }
        if (this.items != null && this.items.getMaxColumNum() > 0) {
            this.sArray[0] += this.byTaskItemChoiceStyle == 1 ? "|奖励物品(任选其一)：" : "|奖励物品：";
        }
        if (this.sArray[0].length() < 1) {
            this.shTextHeight = 0;
        } else {
            //#if NOKIA_S60V5
             this.shTextHeight = (short) Tools.getParagraphHeight(this.sArray[0], Constant.DRAW_WIDTH - 22, Constant.FONT_SMALL_HEIGHT);
            //#else
//#            this.shTextHeight = (short) Tools.getParagraphHeight(this.sArray[0], Constant.DRAW_WIDTH - 22, Constant.FONT_SMALL_HEIGHT);
            //#endif
        }
        
        //Yujiang
        //设置奖金物品touch rect
        setItemTouchRect( Constant.UI_START_Y + 209 + this.shTextHeight + Constant.FONT_SMALL_HEIGHT);
        this.bUiKeyPressLock = false;
        
        //图片资源
        try {
            //弹出层的UI
            //#if NOKIA_S60V5
             this.imgArray = new Image[10];
             this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();            //蓝色的线
             this.imgArray[2] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//弹出层图片
             this.imgArray[3] = ResManager.createImage(90000017); //背景
             this.imgArray[4] = ResManager.createImage(90000044);            //白色的确定取消文字
             this.imgArray[5] = ResManager.createImage(90000043);            //文字图片
             this.imgArray[6] = ResManager.createImage(90000047);            //大数字图片
             this.imgArray[7] = ResManager.createImage(90000084);            //方向键
             this.imgArray[8] = ResManager.createImage(90000085);            //确认
             this.imgArray[9] = ResManager.createImage(90000086); //蓝条
 
            //#else
//#            this.imgArray = new Image[7];
//#            this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();            //蓝色的线
//#            this.imgArray[2] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//弹出层图片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[3] = ResManager.createImage(90000017);
//# //            imgArray[3] = Tools.ZoomImage(imgArray[3], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[3] = ResManager.createImage(90000017); //背景遮罩层图片
            //#endif
//#            this.imgArray[4] = ResManager.createImage(90000044);            //白色的确定取消文字
//#//            this.imgArray[5] = ResManager.createImage(90000043);            //返回文字图片
//#            this.imgArray[6] = ResManager.createImage(90000047);            //大数字图片
            //#endif

        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
            Tools.printLog(e.getMessage());
            Tools.printLog("接受任务界面初始化异常");
        }
        //任务内容的分页
        this.byContentPageSelectIndex = 1;
        //#if NOKIA_S60V5
         this.byMaxContentPage = (byte) Tools.ceil(Tools.getParagraphHeight(this.sTaskDesc, Constant.DRAW_WIDTH - 30, Constant.FONT_SMALL_HEIGHT), Constant.FONT_SMALL_HEIGHT * 5);
        //#elif NOKIA_E72
//#         this.byMaxContentPage = (byte) Tools.ceil(Tools.getParagraphHeight(this.sTaskDesc, Constant.DRAW_WIDTH - 22, Constant.FONT_SMALL_HEIGHT), Constant.FONT_SMALL_HEIGHT * 3);
        //#else
//#        this.byMaxContentPage = (byte) Tools.ceil(Tools.getParagraphHeight(this.sTaskDesc, Constant.DRAW_WIDTH - 22, Constant.FONT_SMALL_HEIGHT), Constant.FONT_SMALL_HEIGHT * 4);
        //#endif
        this.byMaxSelectIndex = 5;
        this.byItemSelectIndex = -1;
        //byTaskUiState (1，接受，2查询,3完成任务)
        this.byShowAcceptArrow = -1;
        Tools.printLog("this.sTaskKey=" + this.sTaskKey);
        this.byItemSelectIndex = 1;
        switch (this.byTaskUiState) {
            case 1:
                this.bySelectIndex = 3;
                this.iPositionY = Constant.UI_START_Y + 252 + Constant.FONT_SMALL_HEIGHT + 2;
                break;
            case 2:
                this.bySelectIndex = 3;
                this.iPositionY = Constant.UI_START_Y + 252 + Constant.FONT_SMALL_HEIGHT + 2;
                break;
            case 3:
                short shItemNum;
                if (this.items != null) {
                    shItemNum = this.items.getMaxColumNum();
                } else {
                    shItemNum = 0;
                }
                if (shItemNum > 0) {
                    this.bySelectIndex = 2;
                    this.iPositionY = Constant.UI_START_Y + 245;
                    if (byItemJobLimit == 1) {
                        for (byte i = 0; i < shItemNum; i++) {
                            if (this.items.getGoodsJob(i) == MainLogic.getInstance().gamePlayer.iplayerOccupation || this.items.getGoodsJob(i) == 0) {
                                this.byItemSelectIndex = (byte) (i + 1);
                            }
                        }
                    }
                } else {
                    this.bySelectIndex = 5;
                    this.iPositionY = Constant.UI_START_Y + Constant.DRAW_HEIGHT - 3;
                }
                break;
        }
        switch (this.byTaskUiState) {
            case 1:
                //接受任务,返回
                this.sArray[3] = "接受任务";
                break;
            case 2:
                //放弃任务
                this.sArray[3] = "放弃任务";
                break;
            case 3:
                //完成任务
                this.sArray[3] = "完成任务";
                break;
        }
        Tools.printLog("this.byTaskUiState=" + this.byTaskUiState);
        switch (this.byTaskUiState) {
            case 1:
                //接受任务,返回
                this.sArray[3] = "接受任务";
                break;
            case 2:
                //放弃任务
                this.sArray[3] = "放弃任务";
                break;
            case 3:
                //完成任务
                this.sArray[3] = "完成任务";
                break;
        }
        MainCanvas.clearInput();
    }

    /**
     * 更新任务
     */
    public void updateTask() {
        if (!GameBean.b_WAIT_NET_MSG_BACK) {
            switch (this.byUiState) {
                case 0:
                    if (!bUiKeyPressLock) {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                            if (this.byContentPageSelectIndex > 1) {
                                byContentPageSelectIndex = (byte) (byContentPageSelectIndex - 1);
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                            if (this.byContentPageSelectIndex < this.byMaxContentPage) {
                                this.byContentPageSelectIndex += 1;
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                            if (this.items != null && this.items.getMaxColumNum() > 1 && this.byItemSelectIndex > 1) {
                                this.byItemSelectIndex -= 1;
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                            if (this.items != null && this.items.getMaxColumNum() > 1 && this.byItemSelectIndex < this.items.getMaxColumNum()) {
                                this.byItemSelectIndex += 1;
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_0, false) && this.items != null && this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                            MainLogic.getInstance().uiInterFace.sysMessage.checkStoreItem(this.items.getGoodsAlias((short) (this.byItemSelectIndex - 1)), this.items.getGoodsColor((short) (this.byItemSelectIndex - 1)), this.items.icon[this.byItemSelectIndex - 1], this.items.getGoodsKey((short) (this.byItemSelectIndex - 1)));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                            switch (this.byTaskUiState) {
                                case 1:
                                    //接受任务
                                    if (this.acceptTask()) {
                                        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                                    }
                                    break;
                                case 2:
                                    //放弃任务
                                    //0,未接,1,已接没有完成，2，已经完成，3，失败
                                    this.byUiState = 2;
                                    break;
                                case 3:
                                    //完成任务
                                    this.finishTask();
                                    break;
                            }
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            this.iPositionY = Tools.updateLinePos(iArray, this.iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bUiKeyPressLock = false;
                            }
                        }
                    }
                    break;
                case 2:
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                        this.giveUpTask();
                    } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                        this.byUiState = 0;
                    }
                    break;
            }
        }
        MainCanvas.clearInput();
    }

    /**
     * 绘制任务界面
     * @param g 
     */
    public void drawTask(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[3], this.imgArray[7], this.imgArray[8], this.imgArray[9], null, this.sTaskName);
         //任务的内容
         Tools.drawParagraph(g, Constant.UI_START_X + 15, Constant.UI_START_Y + 50 - (this.byContentPageSelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT * 5), Constant.DRAW_WIDTH - 30, this.sTaskDesc, 0xFFFFFF, Constant.FONT_SMALL_HEIGHT, -1, Constant.UI_START_Y + 50, Constant.FONT_SMALL_HEIGHT * 5);
         //绘制翻页
         Tools.drawPage(g, this.byMaxContentPage, this.byContentPageSelectIndex, this.imgArray[6], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxContentPage, this.byContentPageSelectIndex)) >> 1), Constant.UI_START_Y + 180);
         Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + 195, Constant.DRAW_WIDTH);
         //绘制金钱和修为经验奖励
         Tools.drawParagraph(g, Constant.UI_START_X + 15, Constant.UI_START_Y + 207, Constant.DRAW_WIDTH - 30, this.sArray[0], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT, -1);
         if (this.items != null && this.items.getMaxColumNum() > 0) {
             //当前被选中的奖品的名称
             if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                 this.items.drawGoodsName(g, (short) (this.byItemSelectIndex - 1), Constant.UI_START_X + 15, Constant.UI_START_Y + 208 + this.shTextHeight);
             }
             //绘制奖励物品
             for (byte i = 0; i < this.items.getMaxColumNum(); i++) {
                 this.items.drawGoods(g, Constant.UI_START_X + 15 + i * 45, Constant.UI_START_Y + 209 + this.shTextHeight + Constant.FONT_SMALL_HEIGHT, i);
                 if (this.byItemSelectIndex - 1 == i) {
                     items.drawSelectStyle(g, Constant.UI_START_X + 15 + i * 45, Constant.UI_START_Y + 209 + this.shTextHeight + Constant.FONT_SMALL_HEIGHT);
                 }
             }
         }
 
         //底部的确定取消
         g.drawRegion(this.imgArray[5], 100, 0, 44, 24, Constant.TRANS_NONE, Constant.UI_START_X + 12, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 38, Graphics.TOP | Graphics.LEFT);
         if (this.byTaskUiState == 1) {
             //接受任务,返回
             g.drawRegion(this.imgArray[5], 0, 52, 94, 25, Constant.TRANS_NONE, Constant.UI_START_X + 254, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 38, Graphics.TOP | Graphics.LEFT);
         } else if (this.byTaskUiState == 2) {
             //放弃任务
             g.drawRegion(this.imgArray[5], 196, 52, 96, 24, Constant.TRANS_NONE, Constant.UI_START_X + 252, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 38, Graphics.TOP | Graphics.LEFT);
         } else if (this.byTaskUiState == 3) {
             //完成任务
             g.drawRegion(this.imgArray[5], 101, 53, 94, 23, Constant.TRANS_NONE, Constant.UI_START_X + 254, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 38, Graphics.TOP | Graphics.LEFT);
         }
         switch (this.byUiState) {
             case 0:
                 break;
             case 2:
                 Tools.drawPopUp(g, (byte) 4, Constant.UI_START_X + 25, Constant.UI_START_Y + ((Constant.END_LINE - 120) >> 1), 310, 120, this.imgArray[2], 0x989898, imgArray[4], 22, 0, 21, 10, imgArray[4], 0, 0, 22, 10, this.sArray[1], this.sArray[2]);
                 break;
         }
        //#else
//#
        //#if NOKIA_S40V3 || NORMAL_240_400 || MOTO || K790
//#         Tools.drawFrame(g, null, null, this.sArray[3], this.sArray[4], this.sTaskName);
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[3], this.sArray[3], this.sArray[4], this.sTaskName);
        //#else
//#        Tools.drawFrame(g, this.imgArray[3], this.imgArray[1], this.sArray[3], this.sArray[4], this.sTaskName);
        //#endif
//#        //顶部的任务标题
//#        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + 30, Constant.DRAW_WIDTH);
//#
        //#if NOKIA_E72
//#         this.iStartY = Constant.UI_START_Y + 35;
//#         //任务的内容 
//#         Tools.drawParagraph(g, Constant.UI_START_X + 11, this.iStartY - (this.byContentPageSelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT * 3), Constant.DRAW_WIDTH - 22, this.sTaskDesc, 0xFFFFFF, Constant.FONT_SMALL_HEIGHT, -1, this.iStartY, Constant.FONT_SMALL_HEIGHT * 3);
//#         this.iStartY += Constant.FONT_SMALL_HEIGHT * 3 + 5;
//#         //绘制翻页
//#         Tools.drawPage(g, this.byMaxContentPage, this.byContentPageSelectIndex, this.imgArray[6], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxContentPage, this.byContentPageSelectIndex)) >> 1), this.iStartY);
//#         this.iStartY += 10;
        //#else
//#        this.iStartY = Constant.UI_START_Y + 39;
//#        //任务的内容 
//#        Tools.drawParagraph(g, Constant.UI_START_X + 11, Constant.UI_START_Y + 39 - (this.byContentPageSelectIndex - 1) * (Constant.FONT_SMALL_HEIGHT * 4), Constant.DRAW_WIDTH - 22, this.sTaskDesc, 0xFFFFFF, Constant.FONT_SMALL_HEIGHT, -1, Constant.UI_START_Y + 39, Constant.FONT_SMALL_HEIGHT * 4);
//#        this.iStartY += Constant.FONT_SMALL_HEIGHT * 4 + 5;
//#        //绘制翻页
//#        Tools.drawPage(g, this.byMaxContentPage, this.byContentPageSelectIndex, this.imgArray[6], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxContentPage, this.byContentPageSelectIndex)) >> 1), this.iStartY);
//#        this.iStartY += 10;
        //#endif
//#        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartY, Constant.DRAW_WIDTH);
//#        //绘制金钱和修为经验奖励
//#        iStartY += 5;
//#        Tools.drawParagraph(g, Constant.UI_START_X + 11, iStartY, Constant.DRAW_WIDTH - 22, this.sArray[0], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT, -1);
//#        iStartY += this.shTextHeight;
//#        if (this.items != null && this.items.getMaxColumNum() > 0) {
//#            //当前被选中的奖品的名称
//#            if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                //#if NOKIA_E72
//#                 this.items.drawGoodsName(g, (short) (this.byItemSelectIndex - 1), Constant.UI_START_X + 11 + Constant.FONT_SMALL.stringWidth(this.byTaskItemChoiceStyle == 1 ? "奖励物品(任选其一)：" : "奖励物品："), iStartY - Constant.FONT_SMALL_HEIGHT);
                //#else
//#                this.items.drawGoodsName(g, (short) (this.byItemSelectIndex - 1), Constant.UI_START_X + 11, iStartY);
//#                iStartY += Constant.FONT_SMALL_HEIGHT;
                //#endif
//#            }
//#            //绘制奖励物品
//#            for (byte i = 0; i < this.items.getMaxColumNum(); i++) {
//#                this.items.drawGoods(g, Constant.UI_START_X + 10 + i * 32, iStartY, i);
//#                if (this.byItemSelectIndex - 1 == i) {
//#                    items.drawSelectStyle(g, Constant.UI_START_X + 10 + i * 32, iStartY);
//#                }
//#            }
//#        }
//#        switch (this.byUiState) {
//#            case 0:
//#                break;
//#            case 2:
//#                Tools.drawPopUp(g, (byte) 4, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 80) >> 1), 232, 80, this.imgArray[2], 0x989898, imgArray[4], 0, 0, 22, 10, imgArray[4], 22, 0, 21, 10, "提示", "确定要放弃这个任务么?");
//#                break;
//#        }
        //#endif
         
         
         ////////
         //Yujiang
         MainView.drawTouchRect(g, mPackagePageTouchRect);
         if(mItemTouchRect != null)
        	 MainView.drawTouchRect(g, mItemTouchRect);
    }

    /**
     * 清除任务资源界面
     */
    public void clearTask() {
        this.sTaskDesc = null;
        this.sTaskTarget = null;
        this.items = null;
        this.imgArray = null;
        this.iArray = null;
        this.sArray = null;
        this.sSenceKey = null;
        this.iTaskCoordinate = null;
        this.sTaskName = null;
        this.sTaskKey = null;
        this.bySingleTaskState = -1;
    }

    /**
     * 获得任务的类型
     * @param sTaskKey
     * @return 
     */
    private String getTaskNamePre(String sTaskKey, byte byType) {
        //绘制类型，绘制等级，绘制任务名称名称
        if (sTaskKey == null) {
            return "";
        }
        char num = sTaskKey.charAt(0);
        if (byType == 1) {
            switch (num) {
                case '1':
                    return "【主线】";
                case '2':
                    return "【支线】";
                case '3':
                    return "【日常】";
                case '4':
                    return "【帮派】";
                case '5':
                    return "【副本】";
                case '6':
                    return "【活动】";
                default:
                    return "";
            }
        } else {
            switch (num) {
                case '1':
                    return "【主】";
                case '2':
                    return "【支】";
                case '3':
                    return "【日】";
                case '4':
                    return "【帮】";
                case '5':
                    return "【副】";
                case '6':
                    return "【活】";
                default:
                    return "";
            }

        }
    }

    public int funcKeyToType(String sFuncKey) {
        if (sFuncKey == null || sFuncKey.length() < 10 || !sFuncKey.substring(0, 9).equals("shuoming_")) {
            return -1;
        }
        sFuncKey = sFuncKey.substring(9);
        if (!Tools.isNumeric(sFuncKey)) {
            return -1;
        } else {
            return Integer.parseInt(sFuncKey);
        }
    }
    /*************************功能说明界面***************************************************************************/
    /**
     * 打开功能说明界面
     */
    private String[] sDescList;
    public short[] shDescHeight;

    public void openFuncDesc(String funcName, String sFuncKey) {
        int byFuncType = funcKeyToType(sFuncKey);
        if (byFuncType == -1 || byFuncType < 1 || byFuncType > 12) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "暂时没有这项功能说明!");
            return;
        }
        String sTemp;
        if (byFuncType >= 1 && byFuncType <= 3) {
            if (byFuncType == 2) {
                sTemp = MainLogic.getInstance().uiInterFace.sysMessage.readTXT("/res/fDesc1.txt", '#', byFuncType, (short) 4096);
            } else {
                sTemp = MainLogic.getInstance().uiInterFace.sysMessage.readTXT("/res/fDesc1.txt", '#', byFuncType, (short) 2048);
            }
        } else {
            sTemp = MainLogic.getInstance().uiInterFace.sysMessage.readTXT("/res/fDesc2.txt", '#', byFuncType - 3, (short) 2048);
        }
        if (sTemp == null || sTemp.length() == 0) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "暂时没有这项功能说明!");
            return;
        }
        char cTemp;
        int place = 0;
        sTemp.trim();
        Vector sVector = new Vector();
        for (int i = 0; i < sTemp.length(); i++) {
            cTemp = sTemp.charAt(i);
            if (cTemp == '|') {
                sVector.addElement(sTemp.substring(place, i));
                place = i + 1;
            } else if (i + 1 == sTemp.length()) {
                sVector.addElement(sTemp.substring(place, sTemp.length()));
            }
        }
        if (sVector.size() == 0) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "暂时没有这项功能说明!");
            return;
        }
        sDescList = new String[sVector.size()];
        sVector.copyInto(sDescList);
        sVector = null;
        sTemp = null;
        MainLogic.getInstance().pushState(Constant.GAME_UI_FUNC_DESC, true);
        this.sArray = new String[]{funcName, ".", "确定", "返回"};
    }

    public void initFuncDesc() {
        preStartY = 0;
        shDescHeight = new short[this.sDescList.length];
        this.iHeight = 0;
        //#if NOKIA_S60V5
         this.shHeight = (short) ((Constant.FONT_SMALL_HEIGHT + 2) * 16);
         for (byte i = 0; i < this.sDescList.length; i++) {
             shDescHeight[i] = (short) Tools.getParagraphHeight(this.sDescList[i], 300, Constant.FONT_SMALL_HEIGHT + 2);
             this.iHeight += shDescHeight[i];
         }
        //#elif NOKIA_E72
//#         this.shHeight = (short) ((Constant.FONT_SMALL_HEIGHT + 2) * 9);
//#         for (byte i = 0; i < this.sDescList.length; i++) {
//#             shDescHeight[i] = (short) Tools.getParagraphHeight(this.sDescList[i], 260, Constant.FONT_SMALL_HEIGHT + 2);
//#             this.iHeight += shDescHeight[i];
//#         }
        //#else
//#        this.shHeight = (short) ((Constant.FONT_SMALL_HEIGHT + 2) * 13);
//#        for (byte i = 0; i < this.sDescList.length; i++) {
//#            shDescHeight[i] = (short) Tools.getParagraphHeight(this.sDescList[i], 180, Constant.FONT_SMALL_HEIGHT + 2);
//#            this.iHeight += shDescHeight[i];
//#        }
        //#endif
        this.byPageIndex = 1;
        this.byMaxPage = (byte) Tools.ceil(this.iHeight, this.shHeight);
        this.iArray = new int[2];
        this.iArray[0] = 0;
        if (this.byMaxPage == 1) {
            this.iArray[1] = this.sDescList.length;
        } else {
            this.iArray[1] = 0;
            this.iHeight = 0;
            for (byte i = 0; i < this.sDescList.length; i++) {
                this.iHeight += shDescHeight[i];
                if (this.iHeight < this.shHeight) {
                    this.iArray[1] += 1;
                } else {
                    this.iArray[1] += 1;
                    break;
                }
            }
        }
        preStartY = 0;
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[8];
             this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
             this.imgArray[2] = ResManager.createImage(90000043);            //查看确定图片
             this.imgArray[3] = ResManager.createImage(90000017);            //背景图片
             this.imgArray[4] = ResManager.createImage(90000047);//大数字图片
             this.imgArray[5] = ResManager.createImage(90000084);            //方向键
             this.imgArray[6] = ResManager.createImage(90000085);            //确定
             this.imgArray[7] = ResManager.createImage(90000086);            //蓝条
            //#elif NORMAL_240_400
//#             this.imgArray = new Image[5];
//#             this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
//#             this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
//# //            this.imgArray[2] = ResManager.createImage(90000043);            //查看确定图片
//#             this.imgArray[3] = ResManager.createImage(90000017);//背景图片;
//#             imgArray[3] = Tools.ZoomImage(imgArray[3], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
//#             this.imgArray[4] = ResManager.createImage(90000047);//大数字
            //#else
//#            this.imgArray = new Image[5];
//#            this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
//#//            this.imgArray[2] = ResManager.createImage(90000043);            //查看确定图片
//#            this.imgArray[3] = ResManager.createImage(90000017);//背景图片;
//#            this.imgArray[4] = ResManager.createImage(90000047);//大数字
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
            Tools.printLog("初始化任务列表界面出错");
        }

    }
    int preStartY = 0;

    public void updateFuncDesc() {
        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
            if (this.byPageIndex > 1) {
                this.byPageIndex -= 1;
                if (this.byPageIndex == 1) {
                    preStartY = 0;
                    this.iArray[0] = 0;
                    this.iArray[1] = 0;
                    this.iHeight = 0;
                    for (byte i = 0; i < this.sDescList.length; i++) {
                        this.iHeight += shDescHeight[i];
                        if (this.iHeight < this.shHeight) {
                            this.iArray[1] += 1;
                        } else {
                            this.iArray[1] += 1;
                            break;
                        }
                    }
                } else {
                    int iStartHeight = (this.byPageIndex - 1) * this.shHeight;
                    int iEndHeight = this.byPageIndex * this.shHeight;
                    this.iArray[0] = 0;
                    this.iHeight = 0;
                    for (byte i = 0; i < this.sDescList.length; i++) {
                        this.iHeight += shDescHeight[i];
                        if (this.iHeight < iStartHeight) {
                            this.iArray[0] += 1;
                        } else {
//                        this.iArray[0] += 1;
                            preStartY = shDescHeight[i] - (this.iHeight - iStartHeight);
                            break;
                        }
                    }
                    this.iHeight = 0;
                    this.iArray[1] = 0;
                    for (byte i = 0; i < this.sDescList.length; i++) {
                        this.iHeight += shDescHeight[i];
                        if (this.iHeight < iEndHeight) {
                            this.iArray[1] += 1;
                        } else {
                            this.iArray[1] += 1;
                            break;
                        }
                    }
                }
            }
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
            if (this.byPageIndex < this.byMaxPage) {
                this.byPageIndex += 1;
                int iStartHeight = (this.byPageIndex - 1) * this.shHeight;
                int iEndHeight = this.byPageIndex * this.shHeight;
                this.iArray[0] = 0;
                this.iHeight = 0;
                for (byte i = 0; i < this.sDescList.length; i++) {
                    this.iHeight += shDescHeight[i];
                    if (this.iHeight < iStartHeight) {
                        this.iArray[0] += 1;
                    } else {
//                        this.iArray[0] += 1;
                        preStartY = shDescHeight[i] - (this.iHeight - iStartHeight);
                        break;
                    }
                }
                this.iHeight = 0;
                this.iArray[1] = 0;
                for (byte i = 0; i < this.sDescList.length; i++) {
                    this.iHeight += shDescHeight[i];
                    if (this.iHeight < iEndHeight) {
                        this.iArray[1] += 1;
                    } else {
                        this.iArray[1] += 1;
                        break;
                    }
                }
            }
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE,
                false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE,
                false)) {
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
        }
    }

    public void drawFuncDesc(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[3], this.imgArray[5], this.imgArray[6], this.imgArray[7], this.imgArray[2], this.sArray[0]);
         this.iStartX = Constant.UI_START_X + 40;
         this.iStartY = Constant.UI_START_Y + 50;
         g.setClip(Constant.UI_START_X + 20, this.iStartY, Constant.DRAW_WIDTH - 20, this.shHeight);
         this.iStartY -= this.preStartY;
         for (int i = this.iArray[0]; i < this.iArray[1]; i++) {
             //首先绘制数字
             g.setColor(0xFFFFFF);
             g.drawString(String.valueOf(i + 1) + this.sArray[1], Constant.UI_START_X + 20, this.iStartY, 0);
             Tools.drawParagraph(g, iStartX, iStartY, 300, this.sDescList[i], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT + 2, 0x000000);
             this.iStartY += this.shDescHeight[i];
         }
         g.setClip(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
         Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[4], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24);
        //#else
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[3], this.sArray[2], this.sArray[3], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[3], this.imgArray[1], this.sArray[2], this.sArray[3], this.sArray[0]);
        //#endif
//#        this.iStartX = Constant.UI_START_X + 40;
//#        this.iStartY = Constant.UI_START_Y + 30;
//#        g.setClip(Constant.UI_START_X + 15, this.iStartY, Constant.DRAW_WIDTH - 15, this.shHeight);
//#        this.iStartY -= this.preStartY;
//#        for (int i = this.iArray[0]; i < this.iArray[1]; i++) {
//#            //首先绘制数字
//#            g.setColor(0xFFFFFF);
//#            g.drawString(String.valueOf(i + 1) + this.sArray[1], Constant.UI_START_X + 15, this.iStartY, 0);
            //#if NOKIA_E72
//#             Tools.drawParagraph(g, iStartX, iStartY, 260, this.sDescList[i], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT + 2, 0x000000);
            //#else
//#            Tools.drawParagraph(g, iStartX, iStartY, 180, this.sDescList[i], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT + 2, 0x000000);
            //#endif
//#            this.iStartY += this.shDescHeight[i];
//#        }
//#        g.setClip(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
//#        Tools.drawPage(g, this.byMaxPage, this.byPageIndex, this.imgArray[4], this.imgArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byMaxPage, this.byPageIndex)) >> 1), Constant.UI_START_Y + Constant.DRAW_HEIGHT - 12);
        //#endif


    }

    public void clearFuncDesc() {
        this.imgArray = null;
        this.sArray = null;
        this.sDescList = null;
        shDescHeight = null;
    }

    //////////////////////
    //
    public static final int BOX_SIZE = 40;
    public static final int START_X = 15;
    public static final int START_Y = 290;
    public static final int SPACE = 6;
    
    public static int[][] mItemTouchRect = null;
    
    public void setItemTouchRect(int y)
    {
    	if(items != null)
    	{
    		int count = items.getMaxColumNum();
    		mItemTouchRect = new int[count][];
    		for(int i = 0; i < count; i++)
    		{
    			mItemTouchRect[i] = new int[]
    			{
    				START_X + (BOX_SIZE + SPACE) * i,
//    				START_Y,
    				y,
    				BOX_SIZE,BOX_SIZE
    			};
    		}
    	}
    }
    public static int[][] mPackagePageTouchRect = new int[][]{
    	{0,170,180,30},
    	{180,170,180,30},
    	
    };
    public void checkTouchTask(int x, int y)
    {
    	System.out.println("byUiState = " + byUiState);
    	System.out.println("byContentPageSelectIndex = " + byContentPageSelectIndex);
    	System.out.println("byMaxContentPage = " + byMaxContentPage);
    	System.out.println("items = " + items);
    	if(items != null)
    	System.out.println("items.getMaxColumNum() = " + items.getMaxColumNum());
    	System.out.println("byItemSelectIndex = " + byItemSelectIndex);
    	

    	 int touched = MainCanvas.checkTouch(x, y, mPackagePageTouchRect);
    	 if(touched >= 0)
    	 {
    		 if(touched == 0)
    		 {
    			 if (this.byContentPageSelectIndex > 1) 
    			 {
    				 byContentPageSelectIndex = (byte) (byContentPageSelectIndex - 1);
    			 }
    		 }
    		 else
    		 {
    			 if (this.byContentPageSelectIndex < this.byMaxContentPage) {
                     this.byContentPageSelectIndex += 1;
                 }
    		 }
    		 
    		
         } 
    	 else
    	 {
    		 if(mItemTouchRect != null)
    		 {
    			 touched = MainCanvas.checkTouch(x, y, mItemTouchRect);
    			 if(touched >= 0)
    			 {
    				 byItemSelectIndex = (byte) (touched+1);
    			 }
    			 else
        		 {
        			 MainCanvas.checkSoftKey();
        		 }
    		 }
    		 else
    		 {
    			 MainCanvas.checkSoftKey();
    		 }
    	 }
    	
    }
    ///////////////////////////
    //

    public static int[][] mTransferListPageTouchRect =  new int[][]{
    	{128,600,50,30},{190,600,50,30},
    };
    public static int[][] mTransferListTouchRect =  null;
    
    public void setTransferListTouchRect()
    {
    	int startY = 58;
    	int h = 23;
    	if(byNumPerPage > 0)
    	{
    		mTransferListTouchRect = new int[byNumPerPage][];
    		for(int i = 0; i < byNumPerPage; i++)
    		{
    			mTransferListTouchRect[i] = new int[]{
    				0,startY + 	h * i ,360,h
    			};
    		}
    	}
    }
    public void checkTouchTransferList(int x, int y)
    {
    	System.out.println("bySelectIndex = " + bySelectIndex);
    	System.out.println("byPageIndex = " + byPageIndex);
    	System.out.println("byNumPerPage = " + byNumPerPage);
    	System.out.println("byTotalNum = " + byTotalNum);
    	
    	if(mTransferListTouchRect != null)
    	{
    		int touched = MainCanvas.checkTouch(x, y, mTransferListTouchRect);
    		if(touched >= 0)
    		{
    			bySelectIndex = (byte) (touched+1);
    		}
    		else
    		{
    			MainCanvas.checkSoftKey();
    		}
    	}
    	else
    	{
    		int touched = MainCanvas.checkTouch(x, y, mTransferListPageTouchRect);
    		if(touched >= 0)
    		{
    			if(touched ==0)
    			{
    				if(byPageIndex > 1)
    					byPageIndex--;
    			}
    			else
    			{
    				if(byPageIndex < byMaxPage)
    					byPageIndex++;
    			}
    			bySelectIndex = 1;
    		}
    		else
    		{
    			MainCanvas.checkSoftKey();
    		}
    	}
    }
	
}
